Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Windows Server » microsoft.public.windows.server.scripting
Thread: I need a hand

HTVi
TV Discussion Newsgroups

I need a hand
josh lacroix 6/27/2007 2:18:00 PM
Ok I am not a great scripter and hardly use..lets get that out in the open. I
currently have a logon script that I use to push out group membership drive
mappings and printers. I just created a install package for SAP that I would
like to deploy, problem is its an EXE. MSI i would just use GP. First off,
Can I from a VBS call a exe to install? If so, give me a hand with the
scripting.. heres my current script.

'*******************************************************************
'* IFMS Office logon script *
'* assigned as a group policy to the entire IFMS domain *
'* *
'* Created Jan. 28, 2004 Ray Doré *
'* Change history: April 26, 2004 -Ray: added callout to other*
'* scripts *
'* May 4,2005 - Ray: changed order of *
'* drive mappings *
'* *
'*******************************************************************

Const OFFICEADMIN_GROUP = "cn=officeadmin"
Const MANAGEMENT_GROUP = "cn=management"
Const CONSULTANTS_GROUP = "cn=consultants"
Const EMPLOYEES_GROUP = "cn=employees"
Const INITIATIVES_GROUP = "cn=initiatives"
Const ADMINISTRATORS_GROUP = "cn=Domain Admins"
Const TRAINING_GROUP = "cn=training"
Const BASIS_GROUP = "cn=basis_team"

Set wshNetwork = CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)

'The memberOf attribute of the user object can have no entries,
'one, or more than one. You have to account for all three possibilities:

colstrGroups = CurrentUser.memberOf
If IsEmpty(colstrGroups) Then
strGroups = ""
End If
If TypeName(colstrGroups) = "String" Then
strGroups = LCase(colstrGroups)
End If
If TypeName(colstrGroups) = "Variant()" Then
strGroups = LCase(Join(colstrGroups))
End If

'WScript.Echo strGroups
'Training room accounts only
If InStr(strGroups, TRAINING_GROUP) Then
wshNetwork.AddWindowsPrinterConnection "\\ifmssrv3\HP613"
wshNetwork.SetDefaultPrinter "\\ifmssrv3\HP613"
Wscript.Quit
END IF

'map common network drives
on error resume next
wshNetwork.MapNetworkDrive "g:", "\\ifmssrv3\ifms"
wshNetwork.MapNetworkDrive "m:", "\\ifmssrv3\documentation"
wshNetwork.MapNetworkDrive "j:", "\\ifmssrv3\archives"

'map network drives based on group membership:

If InStr(strGroups, OFFICEADMIN_GROUP) Then
wshNetwork.MapNetworkDrive "o:", "\\ifmssrv3\finance"
wshNetwork.MapNetworkDrive "p:", "\\ifmssrv3\procurement"
wshNetwork.MapNetworkDrive "h:", "\\ifmssrv3\admin"

ElseIf InStr(strGroups, MANAGEMENT_GROUP) Then
wshNetwork.MapNetworkDrive "o:", "\\ifmssrv3\finance"
wshNetwork.MapNetworkDrive "p:", "\\ifmssrv3\procurement"


'ElseIf InStr(strGroups, CONSULTANTS_GROUP) Then
'spaceholder for future needs

'ElseIf InStr(strGroups, EMPLOYEES_GROUP) Then
'spaceholder for future needs

End If

If InStr(strGroups, BASIS_GROUP) Then
wshNetwork.MapNetworkDrive "x:", "\\ifmssrv2\basis$"
End If

'additional drive mappings:
If InStr(strGroups, INITIATIVES_GROUP) Then
wshNetwork.MapNetworkDrive "t:", "\\ifmssrv3\initiatives"
End if

wshnetwork.RemovePrinterConnection "\\sapbld2\hp515"
wshnetwork.RemovePrinterConnection "\\sapbld2\hp617"
wshNetwork.RemovePrinterConnection "\\sapbld2\HP8150"
wshNetwork.removePrinterConnection "\\Sapbld2\HP542"
wshNetwork.removePrinterConnection "\\Sapbld2\HP5500"
wshNetwork.removePrinterConnection "\\ifmssrv3\HP5500"

'Printer mappings
wshNetwork.AddWindowsPrinterConnection "\\ifmssrv3\HP8150"
wshNetwork.AddWindowsPrinterConnection "\\ifmssrv3\HP515"
wshNetwork.AddWindowsPrinterConnection "\\ifmssrv3\HP542"
wshNetwork.AddWindowsPrinterConnection "\\ifmssrv3\HP617"



If InStr(strGroups, "cn=printer_colour") Then
wshNetwork.AddWindowsPrinterConnection "\\ifmssrv3\HP5500 Color"

END if

'set default printer based on location:

If InStr(strGroups, "cn=printer_553") Then
wshNetwork.SetDefaultPrinter "\\ifmssrv3\HP8150"

Elseif InStr(strGroups, "cn=printer_515") Then
wshNetwork.SetDefaultPrinter "\\ifmssrv3\HP515"

ElseIf InStr(strGroups, "cn=printer_617") Then
wshNetwork.SetDefaultPrinter "\\ifmssrv3\HP617"

ElseIf InStr(strGroups, "cn=printer_542") Then
wshNetwork.SetDefaultPrinter "\\ifmssrv3\HP542"

END if

'insert callouts to other scripts here
wshShell.RegWrite
"HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DisableDHCPMediaSense",1,"REG_DWORD"
WshShell.Run("""\\ifmssrv3\software\teemwork\install_Teemwork_client.vbs""")



NOW I want to add this..

WshShell.Run"\\ifmssrv3\software\sapgui\Setup\NwSapSetup.exe /Silent
/Package="IFMSSAP""


would it work? I keep getting ending errors.



Re: I need a hand
"Richard Mueller [MVP]" <rlmueller-nospam[ at ]ameritech.nospam.net> 6/27/2007 3:04:44 PM

"josh lacroix" <joshlacroix[ at ]discussions.microsoft.com> wrote in message
news:61ED0502-7825-4A19-A7C3-02FD0774A610[ at ]microsoft.com...
[Quoted Text]
> Ok I am not a great scripter and hardly use..lets get that out in the
> open. I
> currently have a logon script that I use to push out group membership
> drive
> mappings and printers. I just created a install package for SAP that I
> would
> like to deploy, problem is its an EXE. MSI i would just use GP. First off,
> Can I from a VBS call a exe to install? If so, give me a hand with the
> scripting.. heres my current script.
>
> '*******************************************************************
> '* IFMS Office logon script *
> '* assigned as a group policy to the entire IFMS domain *
> '* *
> '* Created Jan. 28, 2004 Ray Doré *
> '* Change history: April 26, 2004 -Ray: added callout to other*
> '* scripts *
> '* May 4,2005 - Ray: changed order of *
> '* drive mappings *
> '* *
> '*******************************************************************
>
> Const OFFICEADMIN_GROUP = "cn=officeadmin"
> Const MANAGEMENT_GROUP = "cn=management"
> Const CONSULTANTS_GROUP = "cn=consultants"
> Const EMPLOYEES_GROUP = "cn=employees"
> Const INITIATIVES_GROUP = "cn=initiatives"
> Const ADMINISTRATORS_GROUP = "cn=Domain Admins"
> Const TRAINING_GROUP = "cn=training"
> Const BASIS_GROUP = "cn=basis_team"
>
> Set wshNetwork = CreateObject("WScript.Network")
> Set WshShell = WScript.CreateObject("WScript.Shell")
> Set ADSysInfo = CreateObject("ADSystemInfo")
> Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
>
> 'The memberOf attribute of the user object can have no entries,
> 'one, or more than one. You have to account for all three possibilities:
>
> colstrGroups = CurrentUser.memberOf
> If IsEmpty(colstrGroups) Then
> strGroups = ""
> End If
> If TypeName(colstrGroups) = "String" Then
> strGroups = LCase(colstrGroups)
> End If
> If TypeName(colstrGroups) = "Variant()" Then
> strGroups = LCase(Join(colstrGroups))
> End If
>
> 'WScript.Echo strGroups
> 'Training room accounts only
> If InStr(strGroups, TRAINING_GROUP) Then
> wshNetwork.AddWindowsPrinterConnection "\\ifmssrv3\HP613"
> wshNetwork.SetDefaultPrinter "\\ifmssrv3\HP613"
> Wscript.Quit
> END IF
>
> 'map common network drives
> on error resume next
> wshNetwork.MapNetworkDrive "g:", "\\ifmssrv3\ifms"
> wshNetwork.MapNetworkDrive "m:", "\\ifmssrv3\documentation"
> wshNetwork.MapNetworkDrive "j:", "\\ifmssrv3\archives"
>
> 'map network drives based on group membership:
>
> If InStr(strGroups, OFFICEADMIN_GROUP) Then
> wshNetwork.MapNetworkDrive "o:", "\\ifmssrv3\finance"
> wshNetwork.MapNetworkDrive "p:", "\\ifmssrv3\procurement"
> wshNetwork.MapNetworkDrive "h:", "\\ifmssrv3\admin"
>
> ElseIf InStr(strGroups, MANAGEMENT_GROUP) Then
> wshNetwork.MapNetworkDrive "o:", "\\ifmssrv3\finance"
> wshNetwork.MapNetworkDrive "p:", "\\ifmssrv3\procurement"
>
>
> 'ElseIf InStr(strGroups, CONSULTANTS_GROUP) Then
> 'spaceholder for future needs
>
> 'ElseIf InStr(strGroups, EMPLOYEES_GROUP) Then
> 'spaceholder for future needs
>
> End If
>
> If InStr(strGroups, BASIS_GROUP) Then
> wshNetwork.MapNetworkDrive "x:", "\\ifmssrv2\basis$"
> End If
>
> 'additional drive mappings:
> If InStr(strGroups, INITIATIVES_GROUP) Then
> wshNetwork.MapNetworkDrive "t:", "\\ifmssrv3\initiatives"
> End if
>
> wshnetwork.RemovePrinterConnection "\\sapbld2\hp515"
> wshnetwork.RemovePrinterConnection "\\sapbld2\hp617"
> wshNetwork.RemovePrinterConnection "\\sapbld2\HP8150"
> wshNetwork.removePrinterConnection "\\Sapbld2\HP542"
> wshNetwork.removePrinterConnection "\\Sapbld2\HP5500"
> wshNetwork.removePrinterConnection "\\ifmssrv3\HP5500"
>
> 'Printer mappings
> wshNetwork.AddWindowsPrinterConnection "\\ifmssrv3\HP8150"
> wshNetwork.AddWindowsPrinterConnection "\\ifmssrv3\HP515"
> wshNetwork.AddWindowsPrinterConnection "\\ifmssrv3\HP542"
> wshNetwork.AddWindowsPrinterConnection "\\ifmssrv3\HP617"
>
>
>
> If InStr(strGroups, "cn=printer_colour") Then
> wshNetwork.AddWindowsPrinterConnection "\\ifmssrv3\HP5500 Color"
>
> END if
>
> 'set default printer based on location:
>
> If InStr(strGroups, "cn=printer_553") Then
> wshNetwork.SetDefaultPrinter "\\ifmssrv3\HP8150"
>
> Elseif InStr(strGroups, "cn=printer_515") Then
> wshNetwork.SetDefaultPrinter "\\ifmssrv3\HP515"
>
> ElseIf InStr(strGroups, "cn=printer_617") Then
> wshNetwork.SetDefaultPrinter "\\ifmssrv3\HP617"
>
> ElseIf InStr(strGroups, "cn=printer_542") Then
> wshNetwork.SetDefaultPrinter "\\ifmssrv3\HP542"
>
> END if
>
> 'insert callouts to other scripts here
> wshShell.RegWrite
> "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DisableDHCPMediaSense",1,"REG_DWORD"
> WshShell.Run("""\\ifmssrv3\software\teemwork\install_Teemwork_client.vbs""")
>
>
>
> NOW I want to add this..
>
> WshShell.Run"\\ifmssrv3\software\sapgui\Setup\NwSapSetup.exe /Silent
> /Package="IFMSSAP""
>
>
> would it work? I keep getting ending errors.
>
>
>

Quotes embedded in a string, such as the string representing the command
line to be executed, must be doubled. If "IFMSSAP" must be enclosed in
quotes, use (watch line wrapping):

WshShell.Run("\\ifmssrv3\software\sapgui\Setup\NwSapSetup.exe /Silent
/Package=""IFMSSAP""")

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--


Re: I need a hand
josh lacroix 6/27/2007 3:16:08 PM
Richard your the man...See a simple syntax, i knew it was something
small...like I said, I might do scripting once a year for something
small..You saved me allot of pain and personal anguish

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen