'========================================================================== ' ' VBScript: AUTHOR: Ed Wilson , msft, 7/29/2006 ' ' NAME: ' ' COMMENT: Key concepts are listed below: '1.Sample logon script. '2.Runs an additional script '3.Captures the error code from running the additional script '========================================================================== Option Explicit Dim fServer Dim pServer Dim home Dim wshNet Dim ADSysInfo Dim CurrentUser Dim strGroups Dim GroupMember Dim a,b,c Const HR = "cn=hrgroup" Const MARKETING = "cn=marketinggroup" Const SALES = "cn=salesgroup" fServer = "\\london" pServer = "\\london" home = "\\london\users" Set wshNet = CreateObject("WScript.Network") Set ADSysInfo = CreateObject("ADSystemInfo") Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName) strGroups = LCase(Join(CurrentUser.MemberOf)) wshNet.MapNetworkDrive "h:", fServer & "\Users\" & wshNet.UserName WScript.Echo(wshNet.Username & " " & strgroups) Select Case GroupMember case a = InStr(strGroups, HR) HRsub case b = InStr(strGroups, SALES) SalesSub case c = InStr(strGroups, MARKETING) MarketingSub End Select ' *** departmental subs are below ***** Sub HRsub wshNet.MapNetworkDrive "g:",fServer & "\Hr" wshNet.AddWindowsPrinterConnection pServer &"\HrPrinter" wshNet.SetDefaultPrinter pServer & "\HrPrinter" subRunScript End Sub Sub SalesSub wshNet.MapNetworkDrive "s:", fServer & "\Sales" wshNet.AddWindowsPrinterConnection pServer & "\SalesPrinter" wshNet.SetDefaultPrinter pServer & "\SalesPrinter" subRunScript End Sub Sub MarketingSub wshNet.MapNetworkDrive "m:", fServer & "\Marketing" wshNet.AddWindowsPrinterConnection pServer & "\MarketingPrinter" wshNet.SetDefaultPrinter pServer & "\MarketingPrinter" subRunScript End Sub Sub subRunScript Dim objShell Dim intRTN Const HideWindow = 0 Const WaitForReturn = True Set objShell = CreateObject("wscript.shell") intRTN = objShell.run ("CheckForHotFix.vbs",HideWindow,WaitForReturn) If intRTN <> 0 Then WScript.Echo "Error",intRTN,"occurred" End sub