option explicit ' ----------------------------------------------------------------------------------------- ' -------------------------------- C O N S T A N T S -------------------------------------- ' ----------------------------------------------------------------------------------------- Const nHidden = 0 ' Hidden window Const nNormal = 1 ' Normal window Const nMinimised = 7 ' Minimised window Const nMaximised = 3 ' Maximised window Const bWait = 1 ' ----------------------------------------------------------------------------------------- ' ---------------------------------- G L O B A L S ---------------------------------------- ' ----------------------------------------------------------------------------------------- Dim wshShell, wshProEnv, fso, sOS, sDnsDomain, sEMailName, sEmailAlias, sUserDomain, sCommand Dim wshNetwork, sComputerName, sLogonServer, sUserName, sFullName, sWinDir, sDefaultPrinter Dim UserObj, GroupObj Dim RegStub, RegSet ' ----------------------------------------------------------------------------------------- ' -------------------------------- M A I N L I N E -------------------------------------- ' ----------------------------------------------------------------------------------------- ' Create objects set wshShell = WScript.CreateObject("WScript.Shell") set fso = CreateObject("Scripting.FileSystemObject") set wshProEnv = wshShell.Environment("Process") set wshNetwork = WScript.CreateObject("WScript.Network") ' Read Environment sOS = GetEnv("OS") sDnsDomain = GetEnv("DNSDOMAIN") sEMailName = GetEnv("EMAILNAME") sEMailAlias = GetEnv("EMAILALIAS") sUserName = GetEnv("USERNAME") sFullName = GetEnv("FULLNAME") sComputerName = GetEnv("COMPUTERNAME") sUserDomain = GetEnv("USERDOMAIN") sLogonServer = GetEnv("LOGONSERVER") sWinDir = GeTEnv("WINDIR") ' don't let the postlogon script run on the server ! if (sComputerName = "Sun") then msgbox "Please don't log on to the ADMIN Server" & vbcrlf & _ "unless you are an administrator", vbCritical, _ "Unauthorised Server access" WScript.Quit(0) end if ' Screen title wScript.Echo vbCrLf & " POSTLOGON" & vbCrLf ' Ensure folders are empty wScript.Echo ". Flushing Temp folders" 'FlushFolder "C:\temp\Cache" 'FlushFolder "C:\temp\Cookies" 'FlushFolder "C:\temp\History" 'FlushFolder "C:\Temp" ' Standard Folders wScript.Echo ". Creating standard folders" on error resume next ForceFolder "S:\Email" ForceFolder "H:\Favourites" ForceFolder "H:\Favourites\Links" ForceFolder "H:\Data" ForceFolder "H:\Data\My Pictures" ForceFolder "H:\Data\My Templates" ForceFolder "C:\Temp" ForceFolder "C:\temp\Cache" ForceFolder "C:\temp\Cookies" ForceFolder "C:\temp\History" if err.Number<>0 then err.clear MsgBox "Problem creating standard folders" end if ' Standard Urls wScript.Echo ". Creating standard favourites" on error resume next 'ForceInternetShortcut "S:\Favourites\School Favourites.Url", "FILE://J:\" 'ForceInternetShortcut "S:\Favourites\School Intranet.Url", "http://cwww1/" if err.Number<>0 then err.clear MsgBox "Problem creating standard favourites" end if ' Hide Folders wScript.Echo ". Hiding selected folders" on error resume next HideFolder "H:\Favourites\Links" HideFolder "C:\Documents and Settings\" & sUserName & "\Start Menu\Programs\Startup" HideFolder "C:\Documents and Settings\" & sUserName & "\Start Menu\Programs" HideFolder "C:\Documents and Settings\" & sUserName & "\Start Menu" HideFolder "C:\temp" if err.Number<>0 then err.clear MsgBox "Problem hiding folders" end if if IsMember("GGUsrStaff") then ' ' do custom things for users in the group wScript.Echo ". Revealing drive letters Staff " on error resume next SetVisibleDrives "ADEFGHR" if err.Number<>0 then err.clear MsgBox "Problem revealing drive letters" end if else wScript.Echo ". Revealing drive letters Students" on error resume next SetVisibleDrives "AEFHG" if err.Number<>0 then err.clear MsgBox "Problem revealing drive letters" end if end if if IsMember("Domain Admins") then ' ' do custom things for users in the group wScript.Echo ". Revealing drive letters Domain Admins" on error resume next SetVisibleDrives "ABCDEFGHIJKLMNOPQRSTUVWXYZ" if err.Number<>0 then err.clear MsgBox "Problem revealing drive letters" end if end if ' Make drives A-H, K and X visible 'wScript.Echo ". Revealing drive letters" 'on error resume next 'SetVisibleDrives "HG" 'if err.Number<>0 then ' err.clear ' MsgBox "Problem revealing drive letters" 'end if ' Set default printer 'wScript.Echo ". Setting default printer" 'on error resume next 'sDefaultPrinter = "P" & Mid(sComputerName,2,6) & Mid(sComputerName,8,2) & "01" 'sDefaultPrinter = "Canon iR5020 PS3 - Admin" 'wshNetwork.SetDefaultPrinter sDefaultPrinter 'if err.number<>0 then ' MsgBox "Unable to set default printer of " & sDefaultPrinter & " for workstation " & sComputerName ' err.clear 'end if ' ********************************************************************* ' custom area - put extra commands in here ' ' Set Shell Folders for Folders not done in Group Policy ' ' General Reg entries CreateRegistryValue "HKCU\Software\Microsoft\Internet Explorer\Main\RunOnceComplete", "1", "REG_DWORD" CreateRegistryValue "HKCU\Software\Microsoft\Internet Explorer\Main\RunOnceHasShown", "1", "REG_DWORD" wScript.Echo ". Setting Shell Folders" RegSet = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" CreateRegistryValue RegSet & "\Cache", "C:\Temp\Cache", "REG_SZ" CreateRegistryValue RegSet & "\Cookies", "C:\Temp\Cookies", "REG_SZ" 'CreateRegistryValue RegSet & "\Favorites", "j:\ACW", "REG_SZ" CreateRegistryValue RegSet & "\History", "C:\Temp\History", "REG_SZ" CreateRegistryValue RegSet & "\My Music", "H:\", "REG_SZ" CreateRegistryValue RegSet & "\My Pictures", "h:\", "REG_SZ" CreateRegistryValue RegSet & "\My Video", "h:\", "REG_SZ" CreateRegistryValue RegSet & "\Personal", "H:\", "REG_SZ" CreateRegistryValue RegSet & "\Recent", "S:\Recent", "REG_SZ" CreateRegistryValue RegSet & "\Templates", "g:\", "REG_SZ" 'not used 'CreateRegistryValue RegSet & "\Startup", "C:\Document and Settings\All Users\Start Menu\Programs\Startup", "REG_SZ" 'CreateRegistryValue RegSet & "\Local AppData", "__", "REG_SZ" 'CreateRegistryValue RegSet & "\Local Settings", "__", "REG_SZ" ' In policy 'CreateRegistryValue RegSet & "\Start Menu", "C:\WINDOWS\Start Menu", "REG_SZ" 'CreateRegistryValue RegSet & "\Programs", "C:\WINDOWS\Start Menu\Programs", "REG_SZ" 'CreateRegistryValue RegSet & "\Desktop", "C:\Windows\Desktop", "REG_SZ" ' Special settings for Admin and staff if IsMember("GGUsrStaff") then ' ' do custom things for users in the group wScript.Echo ". Setting Favourites Admin & Staff " on error resume next CreateRegistryValue RegSet & "\Favorites", "H:\Favourites", "REG_SZ" if err.Number<>0 then err.clear MsgBox "Problem setting favourites" end if else ' ' do custom things for users in the group wScript.Echo ". Setting Favourites Students" on error resume next CreateRegistryValue RegSet & "\Favorites", "j:\ACW", "REG_SZ" if err.Number<>0 then err.clear MsgBox "Problem setting favourites" end if end if ' ' 'Set User Shell Folders for Folders not done in Group Policy ' RegSet = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" CreateRegistryValue RegSet & "\Cache", "C:\Temp\Cache", "REG_SZ" CreateRegistryValue RegSet & "\Cookies", "C:\Temp\Cookies", "REG_SZ" 'CreateRegistryValue RegSet & "\Favorites", "J:\ACW", "REG_SZ" CreateRegistryValue RegSet & "\History", "C:\Temp\History", "REG_SZ" CreateRegistryValue RegSet & "\My Music", "H:\", "REG_SZ" CreateRegistryValue RegSet & "\My Pictures", "h:\", "REG_SZ" CreateRegistryValue RegSet & "\My Video", "h:\", "REG_SZ" CreateRegistryValue RegSet & "\Personal", "H:\", "REG_SZ" CreateRegistryValue RegSet & "\Recent", "S:\Recent", "REG_SZ" CreateRegistryValue RegSet & "\Templates", "g:\", "REG_SZ" 'not used 'CreateRegistryValue RegSet & "\Startup", "C:\WINDOWS\Start Menu\Programs\Startup", "REG_SZ" 'CreateRegistryValue RegSet & "\Local AppData", "__", "REG_SZ" 'CreateRegistryValue RegSet & "\Local Settings", "__", "REG_SZ" ' In policy 'CreateRegistryValue RegSet & "\Start Menu", "C:\WINDOWS\Start Menu", "REG_SZ" 'CreateRegistryValue RegSet & "\Programs", "C:\WINDOWS\Start Menu\Programs", "REG_SZ" 'CreateRegistryValue RegSet & "\Desktop", "C:\Windows\Desktop", "REG_SZ" ' Special settings for Admin and staff if IsMember("GGUsrStaff") then ' ' do custom things for users in the group wScript.Echo ". Setting Favourites Admin & Staff " on error resume next CreateRegistryValue RegSet & "\Favorites", "H:\Favourites", "REG_SZ" if err.Number<>0 then err.clear MsgBox "Problem setting favourites" end if else ' ' do custom things for users in the group wScript.Echo ". Setting Favourites Students" on error resume next CreateRegistryValue RegSet & "\Favorites", "j:\ACW", "REG_SZ" if err.Number<>0 then err.clear MsgBox "Problem setting favourites" end if end if 'run the outlook configuration script ' sCommand = "cscript //nologo " & sLogonserver & "\netlogon\outlook2000\outlook.vbs" ' RunExternal sCommand, nNormal, bWait 'run aida for workstation identification ' sCommand = "N:\App\Aida32\Aida32.exe /R g:\Admin\PCReports\%computername% /TEXT" ' RunExternal sCommand, nNormal, bWait ForceDesktopShortcut "Windows Explorer.lnk", "C:\windows\explorer.exe",, "C:\windows", nNormal 'ForceDesktopShortcut "Microsoft Word.lnk", "C:\Program Files\Microsoft Office\Office\winword.exe","", "", nNormal 'ForceDesktopShortcut "Calendar Manager.lnk", "p:calendar\ccwin.exe","2002\sss2002calendar.ce3", "p:\calendar", nNormal 'ForceDesktopShortcut "Events.lnk", "t:\calendar\sc\sc.htm","", "", nNormal DeleteDesktopShortcut "Microsoft Word.lnk" DeleteDesktopShortcut "Events.lnk" ' if IsMember("GGUsrBackupmonitors") then ' ' do custom things for users in the group ' ForceDesktopShortcut "Backup Log.lnk", "C:\windows\notepad.exe", sLogonServer & "\log$\backup.log", "c:\temp", nNormal ' else ' ' do cusom things for users not in the group ' DeleteDesktopShortcut "Backup Log.lnk" ' end if ' if IsMember("GGUsrCalendar") then ' ' do custom things for users in the group ' ForceDesktopShortcut "Flush Calendar.lnk", "t:\calendar\flushcal.bat", "", "", nNormal ' else ' ' do cusom things for users not in the group ' DeleteDesktopShortcut "Flush Calendar.lnk" ' end if ' if IsMember("GGUsrAdmin") then ' ' do custom things for users in the group ' ForceDesktopShortcut "Kidmap.lnk", "q:\kidmap\kidmap.exe", "", "t:\kidmap\data", nNormal ' else ' ' do cusom things for users not in the group ' DeleteDesktopShortcut "Kidmap.lnk" ' end if motd ("Store your personal data on drive H:" & vbCrLf & _ "Store Curriculum data to be shared on drive G:" & vbCrlf & _ "Store Student data to be Stored on drive H:" & vbCrlf & _ " " & vbCrlf & _ " " & vbCrlf & _ " Printers have been set up for staff and admin !!!" & vbCrlf & _ " " & vbCrlf & _ "") ' ********************************************************************* ' Tempory location for Add printer Scripts ' Variables declaration ' Dim objNet, strComputerName, cmp wScript.Echo ". Setting Printer For Admin & Staff " 'List of available printers '\\sun\HP2015n-Lib ' ' ' ' ' blnLocal = FALSE strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer") For Each objPrinter in colPrinters If objPrinter.Attributes And 64 Then blnLocal = TRUE End If Next If blnLocal = FALSE Then ' Variables declaration Dim objNet, strComputerName, cmp ' Read NetBIOS computer name Set objNet = WScript.CreateObject( "WScript.Network" ) strComputerName = objNet.ComputerName 'Remove obsolete Printers 'objNet.RemovePrinterConnection ( "\\Sun\iR5200 - Admin" ) , true, true 'objNet.RemovePrinterConnection ( "\\Sun\iR5200 - Admin" ) , true, true ' Create printers for computers in Staff Room cmp = InStr( 1, strComputerName, "ACW-STAFF", 1) If cmp > 0 Then objNet.AddWindowsPrinterConnection( "\\Sun\iR5200 - Admin" ) objNet.AddWindowsPrinterConnection( "\\sun\HP2015n-Staff" ) ' objNet.AddWindowsPrinterConnection( "\\Sun\T8024-Admin" ) objNet.AddWindowsPrinterConnection( "\\sun\HP2015n-Admin" ) objNet.SetDefaultPrinter( "\\sun\HP2015n-Staff" ) WScript.Quit End If ' Create printers for computers on Staff Laptops cmp = InStr( 1, strComputerName, "ACW-LT", 1) If cmp > 0 Then ' objNet.AddWindowsPrinterConnection( "\\sun\HP2015n-Lib" ) objNet.AddWindowsPrinterConnection( "\\Sun\HP1200-214" ) objNet.AddWindowsPrinterConnection( "\\Sun\HP1200-102" ) objNet.AddWindowsPrinterConnection( "\\Sun\iR5200 - Admin" ) objNet.AddWindowsPrinterConnection( "\\sun\HP2015n-Staff" ) objNet.AddWindowsPrinterConnection( "\\sun\HP2015n-Admin" ) ' objNet.AddWindowsPrinterConnection( "\\Sun\T8024-Admin" ) objNet.SetDefaultPrinter( "\\sun\HP2015n-Staff" ) WScript.Quit End If ' Create printers for computers in Admin cmp = InStr( 1, strComputerName, "ACW-ADMIN", 1) If cmp > 0 Then objNet.AddWindowsPrinterConnection( "\\Sun\iR5200 - Admin" ) objNet.AddWindowsPrinterConnection( "\\Sun\HP2015n-Staff" ) objNet.AddWindowsPrinterConnection( "\\Sun\T8024-Admin" ) objNet.AddWindowsPrinterConnection( "\\Venus\T8024-Admin" ) objNet.AddWindowsPrinterConnection( "\\sun\HP2015n-Admin" ) ' objNet.SetDefaultPrinter( "\\sun\HP2015n-Admin" ) WScript.Quit End If ' Create printers for computers in Room 102 cmp = InStr( 1, strComputerName, "ACW-102", 1) If cmp > 0 Then objNet.AddWindowsPrinterConnection( "\\Sun\HP1200-102" ) objNet.SetDefaultPrinter( "\\Sun\HP1200-102" ) WScript.Quit End If ' Create printers for computers in Room 214 cmp = InStr( 1, strComputerName, "ACW-214", 1) If cmp > 0 Then objNet.AddWindowsPrinterConnection( "\\Sun\HP1200-214" ) objNet.SetDefaultPrinter( "\\Sun\HP1200-214" ) WScript.Quit End If ' Create printers for computers in Library cmp = InStr( 1, strComputerName, "ACW-Lib", 1) If cmp > 0 Then objNet.AddWindowsPrinterConnection( "\\sun\HP2015n-Lib" ) objNet.SetDefaultPrinter( "\\sun\HP2015n-Lib" ) WScript.Quit End If ' Create printers for computers in Bookhire cmp = InStr( 1, strComputerName, "ACW-Bookhire", 1) If cmp > 0 Then objNet.AddWindowsPrinterConnection( "\\Sun\Ky1800-Lib" ) objNet.SetDefaultPrinter( "\\Sun\Ky1800-Lib" ) WScript.Quit End If ' Create printers for computers in Room 211 cmp = InStr( 1, strComputerName, "ACW-211", 1) If cmp > 0 Then objNet.AddWindowsPrinterConnection( "\\Sun\HP1200-214" ) objNet.SetDefaultPrinter( "\\Sun\HP1200-214" ) WScript.Quit End If End If 'example here of how to remove printers ' objNetwork.RemovePrinterConnection ( "\\Mercury\T8024-Admin" ) ' might need ' objNetwork.RemovePrinterConnection ( "\\Mercury\T8024-Admin" ) , true, true ' objNet.RemovePrinterConnection ( "\\Mercury\T8024-Admin" ) ' WScript.Echo "Check Printers folder NO Printer \\Mercury\T8024-Admin" 'end of Printer setups ' ********************************************************************* 'end of custom area ' ********************************************************************* ' Terminate WScript.Quit(0) ' ----------------------------------------------------------------------------------------- ' -------------------- P R O C E D U R E S & F U N C T I O N S ------------------------ ' ----------------------------------------------------------------------------------------- Private Sub RunExternal( sCommand, nWindow, bWait ) ' wshShell.Run sCommand, nWindow, bWait ' end sub Private Function ScriptHome() ' ScriptHome = left(WScript.ScriptFullName,instrrev(WScript.ScriptFullName,"\")-1) ' end function Private Sub CreateRegistryKey( sKey ) ' const FUDGE = "_DUMMY_" ' wshShell.RegWrite sKey & "\" & FUDGE , "" ,"REG_SZ" wshShell.RegDelete sKey & "\" & FUDGE ' end sub Private Sub CreateRegistryValue( sKey, sValue, sType ) ' wshShell.RegWrite sKey, sValue, sType ' end sub Private Sub DeleteRegistryKey( sKey ) ' wshShell.RegDelete sKey & "\" ' end sub Private Sub DeleteRegistryValue( sValue ) ' wshShell.RegDelete sValue ' end sub Private Sub ForceDesktopShortcut( sName, sTarget, sArgs, sDir, nWindowsStyle ) ' Dim objShortcut, sPath ' sPath = wshShell.SpecialFolders("Desktop") if IsFile(sPath & "\" & sName) then DeleteFile(sPath & "\" & sName) end if ' set objShortcut = wshShell.CreateShortcut(sPath & "\" & sName) objShortcut.WindowStyle = nWindowsStyle objShortcut.TargetPath = sTarget objShortcut.WorkingDirectory = sDir objShortcut.Arguments = sArgs objShortcut.Save ' end sub Private Sub DeleteDesktopShortcut( sName ) ' Dim sPath ' sPath = wshShell.SpecialFolders("Desktop") if IsFile(sPath & "\" & sName) then DeleteFile(sPath & "\" & sName) end if ' end sub Private Sub ForceInternetShortcut( File, Url ) ' Const ForReading = 1, ForWriting = 2, ForAppending = 8 Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 ' Dim f, ts ' if IsFile(File) then DeleteFile(File) end if ' fso.CreateTextFile File Set f = fso.GetFile(File) Set ts = f.OpenAsTextStream(ForWriting, TristateUseDefault) ts.write "[InternetShortcut]" & vbCrLf ts.write "URL=" & url & vbCrLf ts.Close ' End Sub Private Function GetEnv( Variable ) ' GetEnv = wshProEnv(Variable) ' End Function Private Sub ForceFolder( Folder ) ' if not IsFolder(Folder) then CreateFolder(Folder) end if ' End Sub Private Sub FlushFolder( Folder ) ' on error resume next if IsFolder(Folder) then DeleteFolder Folder CreateFolder Folder end if ' End Sub Private Sub CreateFolder( Folder ) ' Dim fol ' on error resume next Set fol = fso.CreateFolder(Folder) if err.number<>0 then MsgBox ("Error # " & CStr(Err.Number) & " " & Err.Description) err.clear exit sub end if ' End Sub Private Sub DeleteFolder( Folder ) ' on error resume next fso.DeleteFolder(Folder) if err.number<>0 then MsgBox ("Error # " & CStr(Err.Number) & " " & Err.Description) err.clear exit sub end if ' End Sub Private Sub DeleteFile( File ) ' on error resume next fso.DeleteFile(File) if err.number<>0 then MsgBox ("Error # " & CStr(Err.Number) & " " & Err.Description) err.clear exit sub end if ' End Sub Private Sub CopyFolder( Folder1, Folder2 ) ' on error resume next fso.CopyFolder Folder1, Folder2, TRUE if err.number<>0 then MsgBox ("Error # " & CStr(Err.Number) & " " & Err.Description) err.clear exit sub end if ' End Sub Private Sub CopyFile( File1, File2 ) ' on error resume next fso.CopyFile File1, File2, TRUE if err.number<>0 then MsgBox ("Error # " & CStr(Err.Number) & " " & Err.Description) err.clear exit sub end if ' End Sub Private Function IsFolder( Folder ) ' on error resume next isFolder = fso.FolderExists(Folder) if err.number<>0 then MsgBox ("Error # " & CStr(Err.Number) & " " & Err.Description) err.clear isFolder = FALSE exit function end if ' End Function Private Function IsFile( File ) ' on error resume next isFile = fso.FileExists(File) if err.number<>0 then MsgBox ("Error # " & CStr(Err.Number) & " " & Err.Description) err.clear isFile = FALSE exit function end if ' End Function Private Sub HideFolder( Folder ) ' Dim f ' on error resume next Set f = fso.GetFolder(Folder) If ((f.attributes and 2)=0) Then f.attributes = f.attributes + 2 End If if err.number<>0 then MsgBox ("Error # " & CStr(Err.Number) & " " & Err.Description) err.clear exit sub end if ' End Sub Private Sub SetVisibleDrives( ByVal s ) ' Const NODRIVES = 67108863 Dim i, n ' on error resume next s = ucase(trim(s)) n = NODRIVES for i=0 to 25 if (InStr(s,chr(65+i))>0) then n = n and (NODRIVES-(2^i)) end if next wshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDrives", n, "REG_DWORD" if err.number<>0 then MsgBox ("Error # " & CStr(Err.Number) & " " & Err.Description) err.clear exit sub end if ' End Sub ' ' ***************************************** ' Custom functions added by Systech ' ***************************************** Function IsMember (sGroup) ' Tests if user is a member of the specified group Set UserObj = GetObject("WinNT://" & sUserDomain &"/" & sUserName) IsMember = False For Each GroupObj In UserObj.Groups If GroupObj.Name = sGroup then IsMember = True exit for End If Next Set GroupObj = Nothing Set UserObj = Nothing End Function function motd(sMessage) msgbox sMessage, vbInformation, "System Announcement" end function Private Sub SetEnv( Variable, Value) wshProEnv(Variable) = Value End sub ' ----------------------------------------------------------------------------------------- ' eof ------------------------------------------------------------------------------------- ' -----------------------------------------------------------------------------------------