' Script created by Arturo Castañeda: 2be run by Arturo, becuase there is olmost NO user interaction. ' Master vbscript ZEN Project. NOT and END User Script. Run at your own risk. ' screipt to be called by aa01, depends on acctions from that script. 'ssid: PARUSD01 '1C567FC607C245FEE13A7DAB38 Option Explicit ON error Resume Next 'comon area to all procedures Dim objWshShell, objEnv, objNetwork, oFSO, oTS, oTS2, sWindir, sPfiles, sComInterpreter, sOS, strComputer Dim sNovell49check, sZenworks7check, strUNCPath, intDFstatus, sGWiseIPcheck, sFireWall Dim objWMIService, objRegistry, sophos7ok, colFiles, objFile, envirovariables, ienopw, nlmcheck Dim Admin_pw_OK, stn919accountOK, sTotals, removexeroxp, scenter_disable, fFormatCvrtr, chansa Dim sDel_info_fldr, sDesktop, sNowinupdate, strHomePage, sDeskT, objEnvUser, sInstallTemp Dim oFolder, sGW_HKCUregpath, sGW_HKLMregpath, TempDir, sIEversion, sYacorrio Const HKEY_CURRENT_USER = &H80000001 Const HKEY_LOCAL_MACHINE = &H80000002 strComputer = "." Set objWshShell = CreateObject("WScript.Shell")' Get the WshShell object. Set objNetwork = CreateObject("Wscript.Network") Set objEnv = objWshShell.Environment("Process")' This line loads Environment Variables Propertys Set objEnvUser = objWshShell.Environment("User") ' This line loads User Environment Variables Propertys Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") set oFSO = Wscript.CreateObject("Scripting.FileSystemObject") ' Load file system object TempDir = objWshShell.ExpandEnvironmentStrings("%Temp%") 'Next line: Disable Open File - Security Warning :http://support.microsoft.com/kb/889815/en-us objEnv("SEE_MASK_NOZONECHECKS") = 1 sNowinupdate = "un-changed" removexeroxp = "Not Found" sDel_info_fldr = "un-changed" fFormatCvrtr = "Not Installed" 'sInstallTemp = objEnv("%var1%") sInstallTemp = "\\10.50.3.170\upd-proj" 'This line depends on the account used on the calling script. sInstallTemp If NOT oFSO.FolderExists(sInstallTemp) Then Set oFolder = oFSO.CreateFolder(sInstallTemp) sWindir = objEnv("WINDIR") ' Environment Variable -Windir- assigned to a variable. sPfiles = objEnv("ProgramFiles") ' Program Files assigned to a variable. sComInterpreter = objEnv("comspec") ' Command interpreter path assigned to a variable. sDesktop = objEnv("USERPROFILE") & "\Desktop\" 'User Desktop path assigned to a variable strUNCPath = "\\linc-adm\sys\PUBLIC\bat-vbs\" 'path to DF command console sGW_HKCUregpath = "HKEY_CURRENT_USER\Software\Novell\GroupWise\Login Parameters\TCP/IP Address\" sGW_HKLMregpath = "HKEY_LOCAL_MACHINE\SOFTWARE\Novell\GroupWise\Client\5.0\DefaultIPAddress\" DAME_CHANSA 'CHECKDPENDANCY 'Not used at this point, because an issue with the runas 'CHECK4DEEPFREEZE 'in win98 file c:\Persis0.sys and on winXP c:\Persi0.sys 'THAW CHECK4WINVERSION CHECK4MCAFEE 'CHECK4NOVELLCL ' using NWgina, does not work if they have sp4 of N. 4.9 CHECK4NOVELLCL_REG 'uses registry CHECK4ZENWORKS7 CHECK4IEVERSION CHECK4STN919 CHECKSOPHOS 'COPINSTALLS If sNovell49check = "no" Then INSTALLNOVELL49 If sZenworks7check = "no" Then INSTALLZEN7 CORRIOTODO MSOFILEFORMAT 'REBOOTLOCALPC ENVIRONMENTv ' Set User Enviroment Variables NOLMHASH IENOASKPW CHANGEADMINPW If stn919accountOK = "no" Then CREATEACCOUNT REMOVE_XEROX_PRINTER 'remove xerox walkup printer driver Disable_security_Center ' Sophos HIPS might stop it. DisableFireWall IE_HOME_PAGE NO_NOVELL_SERVER ' ==== Next section I could not make it to work inside a SUB ==== ' Interactive. will ALLOW you to DELETE local computer accounts that are not on the exception list, and also its profile folder. Dim colAccounts, objFolder, question1, question2 Dim answer1, accname, sophosaccount, adminacc2, objUser, fldrpath Set colAccounts = GetObject("WinNT://" & strComputer & "") Const LocalDocumentsFolder = "C:\Documents and Settings\" Set objFolder = oFSO.GetFolder(LocalDocumentsFolder) 'to delete accounts 'strPCname = objNetwork.ComputerName 'NOt needed question1 = "Do you want to DELETE the following account:? ==> " question2 = "Accounts and its associated profile folder have been processed." _ &Chr(13) & "Some times there are other profiles FOLDERS that you might want to delete." _ & (Chr(13) & Chr(13)) & "Do you want to check for these folders now? " answer1 = "" accname = "" sophosaccount = "SophosSAU" & objNetwork.ComputerName & "0" 'ONLY works if sophos was installed after pc was cloned. adminacc2 = "stn-919" colAccounts.Filter = Array("user") For Each objUser In colAccounts accname = objUser.Name If NOT isException(accname) then ' only continue if item is not on the exception list answer1 = MsgBox (question1 & objUser.Name,4,"Arturo vbs") If answer1 = 6 Then colAccounts.Delete "user", objUser.Name 'delete the account fldrpath = LocalDocumentsFolder & objUser.Name If oFSO.FolderExists(fldrpath) Then oFSO.DeleteFolder fldrpath, True 'this line will delete the folder profile. Else 'Wscript.Echo "NO was clicked" End if Else End if ' If it is a LAB computer also delte Dist-Info folder for all accounts. * W. In progres. IF chansa = chr(76) Then fldrpath = LocalDocumentsFolder & objUser.Name 'Wscript.Echo fldrpath & " value of variable. Inside IF for Dist Info folder" If oFSO.fileExists(fldrpath & "\Desktop\District-info.lnk") then oFSO.Deletefile(fldrpath & "\Desktop\District-info.lnk") sDel_info_fldr = "Deleted" Else 'sDel_info_fldr = "Was OK" End If End If Next answer1 = MsgBox (question2 ,4,"Arturo vbs") ' Ask if you want to Clean orphan folders If answer1 = 6 Then ' Clean Orphan profile folders. ' objWshShell.Run "wscript delete-win-profile02.vbs", , True Dim answer20, question20, fldrname, fldr, a, Title, Message, acaountName Message = "" acaountName = "" answer20 = "" question20 = "Do you want to DELETE the following folder? ==> " fldrname = "" For each fldr in objFolder.SubFolders 'will stract the account name from the folder path a = Split(fldr.path, "\") 'delimeter is \ acaountName = a(UBound(a)) ' text to the right of the last \ assigned to variable 'Wscript.Echo acaountName & " obtained from:" & fldr.path fldrname = acaountName If NOT fldrException(fldrname) then answer20 = MsgBox (question20 & fldrname,4,"Arturo vbs") If answer20 = 6 Then oFSO.DeleteFolder fldr.path, True 'this line will delete the folder. Else ' Wscript.Echo "NO was clicked" End If Else End if Next Title = "WSH " & WScript.ScriptName & " - by A. Castañeda" ' Initialize title text. 'MsgBox Message, vbInformation & vbOKOnly, Title Wscript.Echo "Finished cleaning profile folders" Else 'Wscript.Echo "NO was clicked" End if ' ==== END of section I could not make it to work inside a SUB ==== IF chansa = chr(76) Then LAB If sophos7ok = "no" Then INSTALLSOPHOS ' =========== PREPARE FINAL REPORT =========== sTotals = ("Novell Client 4.9: ") & sNovell49check _ & VBCR & ("Zenworks 7: ") & sZenworks7check _ & VBCR & ("Sophos7 : ") & sophos7ok _ & VBCR & ("GroupWise: ") & sGWiseIPcheck _ & VBCR & ("NO LM Hash: ") & nlmcheck _ & VBCR & ("Enviroment V: ") & envirovariables _ & VBCR & ("Win UPD disabled: ") & sNowinupdate _ & VBCR & ("W. FireWall: ") & sFireWall _ & VBCR & ("MSO fFcvrtr: ") & fFormatCvrtr _ & VBCR & ("IE no rember pw: ") & ienopw _ & VBCR & ("stn-919 acct: ") & stn919accountOK _ & VBCR & ("Admin pw changed: ") & Admin_pw_OK _ & VBCR & ("Xerox Prtr remove: ") & removexeroxp _ & VBCR & ("Dsabl Sec.Ctr: ") & scenter_disable _ & VBCR & ("Dist Info Fldr: ") & sDel_info_fldr _ & VBCR & ("IE home Page: ") & strHomePage set oTS2 = oFSO.CreateTextFile(TempDir & "\todo.txt") oTS2.Close msgbox (sTotals),,"End of code. Results of Verification Test" 'CLEANUP CLEARURLS objEnv.Remove("SEE_MASK_NOZONECHECKS") ' re-Enable the “Open File - Security Warning” previowsly disabled. 'objWshShell.Popup "End of Script. This is the last line of code.",6, "Arturo Castaneda" 'Inform user ' =========== SUBRUTINE: LAB =============== Sub LAB 'objWshShell.Popup "LAB computer",3, "Arturo Castaneda" 'Inform user 4 debuging GWISEIP NOWINUPDATE 'ONLY if DF is ON DEL_DIST_INFO_FLDER 'Use only on STUDENT computers. 'OPEN_Wireless_Properties 'objWshShell.Run "Z:\\TZedit\\TZEDIT.EXE"' Check Time 'objWshShell.Run "rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,1" 'Option to Rename PC 'objWshShell.Run "control Ncpa.cpl,,1" 'Open Nework properties. 'objWshShell.Run "\\linc-adm\sys\PUBLIC\Printers\HP\HP Mobile Printing\hp tcpip printing\mpd4w_XP_ps\Install.exe /q" 'objWshShell.Run "Z:\\DF\\tann2k60.exe"' Run the DF installer 'Add code to use CMD to delete temp files End Sub ' =========== SUBRUTINE: CLEARURLS =============== Sub CLEARURLS ' Clear IE typed URLs 'http://blogs.technet.com/b/heyscriptingguy/archive/2006/05/09/how-can-i-clear-the-list-of-urls-that-appear-in-the-internet-explorer-address-bar.aspx ' Typed URLS only appera in the registry AFTER IE is closed. ' If it is already CLEARED, VBS will generate an error unles you ON Error resuem Next. Dim strKeyPath, strValue, arrValueNames, arrValueTypes strKeyPath = "Software\Microsoft\Internet Explorer\TypedURLs" objRegistry.EnumValues HKEY_CURRENT_USER, strKeyPath, arrValueNames, arrValueTypes For Each strValue in arrValueNames objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValue Next ' ===== ==== ==== ' http://www.howtogeek.com/howto/windows/clear-ie7-browsing-history-from-the-command-line/ ' Next line deletes IE7 history. Does NOT work in IE6 If sIEversion >= "7" Then objWshShell.Run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1" objWshShell.Popup "IE 7 History was cleared. ",2, "Arturo Castaneda" 'Inform user 4 debuging Else objWshShell.Popup "Manualy Clean IE History",3, "Arturo Castaneda" 'Inform user 4 debuging End if End Sub ' =========== SUBRUTINE: CLEANUP =============== Sub CLEANUP ' Delete folders used to install some applications Dim demofolder If oFSO.FolderExists(sInstallTemp) Then objWshShell.Popup "Cleaning UP. Deleting Folder",3, "Arturo Castaneda" 'Inform user 4 debuging set demofolder = oFso.GetFolder(sInstallTemp) demofolder.Delete End if End sub ' =========== SUBRUTINE: NO_NOVELL_SERVER =============== Sub NO_NOVELL_SERVER ' Set Novell Default Server to NONE Dim sKeyPath, sValueName, sValue 'Delete Registry String value sKeyPath = "SOFTWARE\Novell\Location Profiles\Services\{1E6CEEA1-FB73-11CF-BD76-00001B27DA23}\Default\Tab1" sValueName = "Server" sValue = "" objRegistry.SetStringValue HKEY_LOCAL_MACHINE,sKeyPath,sValueName,sValue End sub ' =========== SUBRUTINE: CORRIOTODO =============== Sub CORRIOTODO 'Check if script has run in its entirity If oFSO.FileExists(TempDir & "\todo.txt") Then sYacorrio = MsgBox("Ya corrio todo... Lo quieres hacer de nuevo", vbYesNo, "You might want to EXIT", 100, 200) If sYacorrio = vbYes Then 'Msgbox "You answered yes." 'script will run again Else Wscript.Quit 'Quit script End If Else ' script has never run End If End Sub ' =========== SUBRUTINE: CHECK4WINVERSION =============== Sub CHECK4WINVERSION ' This will determine the OS version based on the command interpreter. if sComInterpreter = "C:\WINDOWS\COMMAND.COM" Then sOS = "W9x" Wscript.Quit ' Exiting the script, because this particular script is intended ONLY for Win2K and XP Else sOS = "2K-or-XP" End if End sub ' =========== SUBRUTINE: COPINSTALLS =============== Sub COPINSTALLS 'If needed copy installation files fron Network to LOCAL drive; for Sophos, Novell and Zen If sophos7ok = "no" Then ' Copy if NEEDED and not yet copied IF NOT oFSO.FolderExists(sInstallTemp & "\esxp") Then IF chansa = chr(76) Then oFSO.CopyFolder "\\linc-adm\SYS\PUBLIC\Cid\esxp-manual", sInstallTemp & "\esxp"'copy Sophos installation Else oFSO.CopyFolder "\\linc-adm\SYS\PUBLIC\Cid\esxp", sInstallTemp & "\esxp"'copy Sophos installation End If objWshShell.Popup "Sophos was copied",1, "Arturo Castaneda" 'Inform user 4 debuging End If End If If sNovell49check = "no" Then If NOT oFSO.FolderExists(sInstallTemp & "\NW491SP3") Then oFSO.CopyFolder "\\linc-adm\SYS\PUBLIC\NW491SP3", sInstallTemp & "\NW491SP3" ' Copy Novell Client installation objWshShell.Popup "Novell Client copied",1, "Arturo Castaneda" 'Inform user 4 debuging End If End If If sZenworks7check = "no" Then If NOT oFSO.FolderExists(sInstallTemp & "\zenworks") Then oFSO.CopyFolder "\\dist-nwfile-adm\DATA\Install\zenworks", sInstallTemp & "\zenworks" ' Copy Zenworks installation objWshShell.Popup "Zenworks Client copied",1, "Arturo Castaneda" 'Inform user 4 debuging End If ' Next section copies script to be run localy after Zen installation reboots pc. IF NOT oFSO.FileExists(sInstallTemp & "\aa-BV.vbs") Then ofso.CopyFile "aa-BV.vbs", sInstallTemp & "\" 'copy MASTER objWshShell.Popup "Master was copied. " & sInstallTemp,1, "Arturo Castaneda" 'Inform user End If End If End sub ' =========== SUBRUTINE: CHECK4MCAFEE =============== sub CHECK4MCAFEE 'Check if McAfee is installed and if so, UN-install it. Dim colSoftware, objSoftware If oFSO.FileExists(sPfiles & "\Common Files\Network Associates\On Demand Scanner\Scan32\scan32.exe") Then 'Test existance mcafee. Set colSoftware = objWMIService.ExecQuery _ ("Select * from Win32_Product Where Name = 'McAfee VirusScan'") 'version 8 shows as: McAfee VirusScan Enterprise For Each objSoftware in colSoftware objSoftware.Uninstall() Next INSTALLSOPHOS Else End if End sub ' =========== SUBRUTINE: IENOASKPW =============== Sub IENOASKPW ' Next section will configure IE so it will not ask on remembering web passwords. Dim regIEsuggPW, regIEsuggPWask regIEsuggPW = "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FormSuggest Passwords" regIEsuggPWask = "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FormSuggest PW Ask" objWshShell.RegWrite regIEsuggPW,"no" objWshShell.RegWrite regIEsuggPWask,"no" ienopw = "OK" End sub ' =========== SUBRUTINE: CHECK4NOVELLCL =============== Sub CHECK4NOVELLCL ' Next section will check for Novell client 4.9 : 'Using Version of NWgina.dll file Dim sNWgina If oFSO.FileExists(sWindir & "\system32\nwgina.dll") Then 'File exist, that means Novell client is installed sNWgina = oFSO.GetFileVersion(sWindir & "\system32\nwgina.dll") If sNWgina < "4.91.3.3" Then ' version of novell sNovell49check = "no" Else sNovell49check = "OK" End if Else sNovell49check = "no" End if objWshShell.Popup sNovell49check & " Novell",1, "Arturo Castaneda" 'Inform user End sub ' =========== SUBRUTINE: CHECK4NOVELLCL_REG =============== Sub CHECK4NOVELLCL_REG ' Next section will check for Novell client 4.9 : 'Using Version from registry ' In N. client 4.9 sp4 They have an older version of NWgina.dll v. 4.91.3.16 ' For that reason we will use registry method instead Dim sNWregpath, regKey, strValueName, strValue sNWregpath = "SOFTWARE\Novell" strValueName = "CurrentVersion" objRegistry.GetStringValue HKEY_LOCAL_MACHINE,sNWregpath,strValueName,strValue 'Wscript.Echo strValueName & " = " & strValue If strValue < "4.91" Then sNovell49check = "no" Else sNovell49check = "OK" End if objWshShell.Popup sNovell49check & " Novell",1, "Arturo Castaneda" 'Inform user End sub ' =========== SUBRUTINE: CHECK4IEVERSION =============== Sub CHECK4IEVERSION ' This sections checks the Version of Internet Explorer : 'Using Version from registry Dim sIEregpath, regKey, strValueName sIEregpath = "SOFTWARE\Microsoft\Internet Explorer" strValueName = "Version" objRegistry.GetStringValue HKEY_LOCAL_MACHINE,sIEregpath,strValueName,sIEversion 'objWshShell.Popup sIEversion & " Version of IE",1, "Arturo Castaneda" 'Inform user End sub ' =========== SUBRUTINE: CHECK4ZENWORKS7 =============== Sub CHECK4ZENWORKS7 ' Next section will check for Zenworks 7. If oFSO.FileExists(sPfiles & "\Novell\ZENworks\NalView.exe") Then sZenworks7check = "OK" ' File exist, that means Zenworks is already installed. Else sZenworks7check = "no" End if objWshShell.Popup sZenworks7check & " Zenworks 7",1, "Arturo Castaneda" 'Inform user End sub ' =========== SUBRUTINE: CHECKSOPHOS =============== Sub CHECKSOPHOS ' Next section will check for Sophos OLD version or x on the shield dim sophosv, sophupdstatus, sophregKey sophos7ok = "OK" IF oFSO.FileExists(sPfiles & "\Sophos\Sophos Anti-Virus\SavMain.exe") Then 'Location of Sophs 6.x and or 7.x sophosv = oFSO.GetFileVersion(sPfiles & "\Sophos\Sophos Anti-Virus\SavMain.exe") 'version of Sophos if sophosv < "1.0.0.3980" then sophos7ok = "no" ' sphos shield in the system tray with red X comes from registry HKLM\Software\Sophos\AutoUpdate\UpdateStatus\Result 'If the reg value is any other number than "0" that means there is something wrong and the shield will have a red X sophupdstatus = "HKEY_LOCAL_MACHINE\Software\Sophos\AutoUpdate\UpdateStatus\Result" sophregKey = objWshShell.RegRead(sophupdstatus) if sophregkey <> 0 Then sophos7ok = "no" Else sophos7ok = "no" End If objWshShell.Popup sophos7ok & " Sophos",1, "Arturo Castaneda" 'Inform user End sub ' =========== SUBRUTINE: CHECK4STN919 =============== Sub CHECK4STN919 ' Check if Windows account STN-919 exists. Dim RunNetUser, FileExist, Line1, CMD, oTemFile, Line1Test CMD = objWshShell.ExpandEnvironmentStrings("%ComSpec% /K") ' after the Net User enter the name of the account you are looking for. RunNetUser = objWshShell.Run(CMD & " Net User stn-919 > %Temp%\NetUser.txt" , 0, False) WScript.Sleep 1000 FileExist = oFSO.FileExists(TempDir & "\NetUser.txt") If FileExist = True Then Set oTemFile = oFSO.OpenTextfile(TempDir & "\NetUser.txt", 1) Do While oTemFile.AtEndOfStream = False Line1 = oTemFile.ReadAll 'If the account exist the text file will contain it's data, otherwise it will be empty Loop If line1 = "" Then 'MsgBox "User Account Does Not Exist" stn919accountOK = "no" Else 'MsgBox "User Account Exists" stn919accountOK = "Already was created" End If End If oTemFile.Close oFSO.DeleteFile (TempDir & "\NetUser.txt") 'Delete temp file Set RunNetUser=Nothing Set FileExist=Nothing Set Line1=Nothing Set CMD=Nothing Set oTemFile=Nothing Set Line1Test=Nothing 'On Error Goto 0 'turn error-handling off End Sub ' =========== SUBRUTINE: INSTALLNOVELL49 =============== Sub INSTALLNOVELL49 'MsgBox sInstallTemp & "\NW491SP3\SETUPNW.EXE /ACU /U:UNATTEND.TXT", vbOKCancel, Title set oTS = oFSO.CreateTextFile ("C:\Novell\491SP3.TXT") oTS.Close 'Next line will lunch the unatended Novell client install. Script will PAUSE untill install finished duet to ",, Trure" objWshShell.Run sInstallTemp & "\NW491SP3\SETUPNW.EXE /ACU /U:UNATTEND.TXT",, True 'Wscript.echo "The installtion of Novell 4.9 should be done or about DONE. " End sub ' =========== SUBRUTINE: REBOOTLOCALPC =============== SUB REBOOTLOCALPC Dim OpSysSet, OpSys 'Netxt section will reboot PC. Needed because at this point pc is detached from the Network. Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//" & strComputer & "/root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true") for each OpSys in OpSysSet OpSys.Reboot() ' Reboot the computer. next End Sub ' =========== SUBRUTINE: INSTALLZEN7 =============== Sub INSTALLZEN7 'because zen7 reboots pc, we will put the script in the runonce objWshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Runonce\postzen7","wscript.exe " & sInstallTemp & "\aa-BV.vbs" objWshShell.Popup "Installing Zenworks 7 ",10, "Arturo Castaneda" 'Inform user 'Next line will lunch the unatended Zenworks 7 install. objWshShell.Run "MSIEXEC /I " & sInstallTemp & "\zenworks\ZDM7SP1\ZFDAGENT.MSI /Qb- ADDLOCAL=WorkstationManager,ApplicationLauncher,MirrorDriver,Imaging STARTUP_APPEXPLORER=1 ZENWORKS_TREE=PUSD_TREE",, True End sub ' =========== SUBRUTINE: MSOFILEFORMAT =============== Sub MSOFILEFORMAT ' Install MS Office 2007 File Format Converter objWshShell.Run sInstallTemp & "\FileFormatConverters.exe /quiet",, True fFormatCvrtr = "Installed" End Sub ' =========== SUBRUTINE: INSTALLSOPHOS =============== Sub INSTALLSOPHOS objWshShell.Popup "Installing Sophos... ",1, "Arturo Castaneda" 'Inform user 'Script will PAUSE untill install finished duet to ",, Trure" IF chansa = chr(76) Then objWshShell.Run sInstallTemp & "\esxp-manual\setup.exe -ni",, True'Install for LAB Else objWshShell.Run sInstallTemp & "\esxp\setup.exe -ni",, True 'Regular install End If sophos7ok = "Fixing" End sub ' =========== SUBRUTINE: ENVIRONMENTv =============== Sub ENVIRONMENTv Dim colUsrEnvVars Set colUsrEnvVars = objWshShell.Environment("USER") 'Duplicated code from line 17 - 2be fixed colUsrEnvVars("TEMP") = "%USERPROFILE%\Local Settings\Temp" colUsrEnvVars("TMP") = "%USERPROFILE%\Local Settings\Temp" envirovariables = "OK" End sub ' =========== SUBRUTINE: NOLMHASH =============== Sub NOLMHASH 'write code to registry using DOS commnd "reg add" ' http://www.computerhope.com/reg.htm Dim scommand scommand = "reg add HKLM\SYSTEM\CurrentControlSet\Control\Lsa /v NoLMHash /t REG_DWORD /f /d ""00000001""" objWshShell.run "%COMSPEC% /C" & scommand, 0, TRUE ' /C closes the command prompt window before you see it! nlmcheck = "OK" objWshShell.Popup " LM-HASH was fixed",1, "Arturo Castaneda" 'Inform user End sub ' =========== SUBRUTINE: GWISEIP =============== Sub GWISEIP ' Make GroupWise IP address the current one. For District: 10.52.190.247 Dim regKey, scommand, regkey2 ' regKey = objWshShell.RegRead(sGW_HKCUregpath) If RegistryKeyExists(sGW_HKCUregpath) Then 'Use Function to check existance of registry 'Wscript.Echo "First GW Regystry KEY found." If (regKey = "10.52.190.247") Then sGWiseIPcheck = "OK" 'MsgBox "IP address is OK " & regKey 'objWshShell.Popup "GW IP address is OK ",2, "Arturo Castaneda" 'Inform user Else objWshShell.RegWrite sGW_HKCUregpath,"10.52.190.247" 'this line changes the IP sGWiseIPcheck = "Fixed" End If Else Wscript.Echo "GroupWise HKCU Regystry KEY does NOT exist" End If '===== Second place we need to check. ===== If NOT RegistryKeyExists(sGW_HKLMregpath) Then 'Use Function to check existance of registry 'If it does NOT exist, then: Create Key 'Wscript.Echo "GroupWise HKLM Regystry KEY does NOT exist. It will be created now" objRegistry.CreateKey HKEY_LOCAL_MACHINE, "SOFTWARE\Novell\GroupWise\Client\5.0\DefaultIPAddress" regkey2 = objWshShell.RegRead(sGW_HKLMregpath) End If If RegistryKeyExists(sGW_HKLMregpath) Then 'Use Function to check existance of registry 'Wscript.Echo "second GW Regystry KEY found." If (regKey2 = "10.52.190.247") Then sGWiseIPcheck = "OK" Else objWshShell.RegWrite sGW_HKLMregpath,"10.52.190.247" 'this line changes the IP sGWiseIPcheck = "Fixed" End if Else 'Wscript.Echo "GroupWise HKLM Regystry KEY does NOT exist" End If ' Set Windows Default email Client to GroupWise using DOS Command line. scommand = "reg add HKLM\Software\Clients\Mail /ve /f /d ""GroupWise""" objWshShell.run "%COMSPEC% /C" & scommand, 0, TRUE ' /C closes the command prompt window before you see it! End sub ' =========== SUBRUTINE: CHANGEADMINPW =============== Sub CHANGEADMINPW 'http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/usersgroups/localusers/ Dim objUser Set objUser = GetObject("WinNT://" & strComputer & "/Administrator,user") objUser.SetPassword "&t3ch&" objUser.SetInfo Admin_pw_OK = "OK" objWshShell.Popup " Administrator pw updated",1, "Arturo Castaneda" 'Inform user End sub ' =========== SUBRUTINE: CREATEACCOUNT =============== Sub CREATEACCOUNT 'Create local User Account dim com, myhost, usr myhost = objWshShell.ExpandEnvironmentStrings("%COMPUTERNAME%") 'for other options use SET at CMD promt. Set com = GetObject("WinNT://" + myhost + ",computer") 'Next line the user name is between last quotes. Set usr = com.Create("user", "stn-919") usr.SetPassword "mkm3$" usr.SetInfo 'Set User Account Password Never Expire usr.Put "UserFlags", usr.Get("UserFlags") Or &H10000 usr.SetInfo ' Add to local group: Administrators, using DOS command "Net localgroup" ' http://technet.microsoft.com/en-us/library/bb490706.aspx ' /c and in convination with ,0 is so the ms DOS black window does not appear. objwshShell.run "%COMSPEC% /C net localgroup Administrators stn-919 /add", 0, TRUE stn919accountOK = "OK" End sub ' =========== SUBRUTINE: REMOVE_XEROX_PRINTER =============== sub REMOVE_XEROX_PRINTER 'If Xerox Walk-up Printer Driver is installed, then unistall it. Dim colSoftware2, objSoftware2 Set colSoftware2 = objWMIService.ExecQuery _ ("Select * from Win32_Product Where Name = 'Xerox Walk-up Printing Driver 2.0'") For Each objSoftware2 in colSoftware2 objSoftware2.Uninstall() removexeroxp = "OK" Next End sub ' =========== SUBRUTINE: DAME_CHANSA =============== Sub DAME_CHANSA chansa = InputBox("How are you doing...", "Arturo C. C.", "You might want to EXIT", 100, 200) If chansa = chr(55) or chansa = chr(76) Then objWshShell.Popup "You are blesed . " & sDeskT,1, "Arturo Castaneda" 'Inform user Else objWshShell.Popup "Final del surco.. . " & sDeskT,2, "Arturo Castaneda" 'Inform user Wscript.Quit End if End Sub ' =========== SUBRUTINE: Disable_security_Center =============== Sub Disable_security_Center ' Disable Security Center Notification. After a Reboot Dim RegLocate, RegLocate1, RegLocate2, RegLocate3 ' 1 turns off monitoring. 0 = ON ' Turns OFF Firewall monitoring in the Windows Security Center RegLocate = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security Center\FirewallDisableNotify" objWshShell.RegWrite RegLocate,"1","REG_DWORD" ' Turns OFF AntiVirus monitoring in the Windows Security Center RegLocate2 = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security Center\AntiVirusDisableNotify" objWshShell.RegWrite RegLocate2,"1","REG_DWORD" ' Turns OFF AutoUpdate monitoring in the Windows Security Center RegLocate3 = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security Center\UpdatesDisableNotify" objWshShell.RegWrite RegLocate3,"1","REG_DWORD" 'msgbox "Script has Finished. Must reboot the computer" scenter_disable = "OK" objWshShell.Popup " Security Center has been disabled",2, "Arturo Castaneda" 'Inform user End Sub ' =========== SUBRUTINE: DisableFireWall =============== Sub DisableFireWall 'Disable Windows Firewall, method using command objWshShell.Run("netsh firewall set opmode mode = disable") sFireWall = "Turned OFF" End Sub ' =========== SUBRUTINE: DEL_DIST_INFO_FLDER =============== Sub DEL_DIST_INFO_FLDER If oFSO.fileExists("C:\Documents and Settings\All Users\Desktop\District-info.lnk") then oFSO.DeleteFile("C:\Documents and Settings\All Users\Desktop\District-info.lnk") sDel_info_fldr = "Deleted" Else 'sDel_info_fldr = "Was OK" End If ' NOTE If it is a LAB PC, the folder is also deleted from the CURRENT logged on user ' from CODE in lines 107 - 116 End Sub ' =========== SUBRUTINE: IE_HOME_PAGE =============== Sub IE_HOME_PAGE strHomePage = "http://www.paramount.k12.ca.us/" objWshShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\Start Page", strHomePage End Sub ' =========== SUBRUTINE: NOWINUPDATE =============== Sub NOWINUPDATE ' http://stackoverflow.com/questions/295563/enable-disable-windows-update-from-a-vbscript Dim objAutoUpdate, objSettings Const AU_DISABLED = 1 Set objAutoUpdate = CreateObject("Microsoft.Update.AutoUpdate") Set objSettings = objAutoUpdate.Settings objSettings.NotificationLevel = AU_DISABLED objSettings.Save sNowinupdate = "OK" End Sub ' =========== SUBRUTINE: CHECKDPENDANCY =============== SUB CHECKDPENDANCY sDeskT = Wscript.Arguments.Item(0) ' passed from calling script. objWshShell.Popup "Checking existance of folder. " & sDeskT & "install",9, "Arturo Castaneda" 'Inform user If NOT oFSO.FolderExists(sDeskT & "install") Then objWshShell.Popup "I am alone and will NOT continue. " & sDeskT,6, "Arturo Castaneda" 'Inform user Wscript.Quit End If END SUB ' =========== SUBRUTINE: THAW =============== Sub THAW If Frozen = True Then objWshShell.Run(strUNCPath & "DFC6 5aa16 /BOOTTHAWED") Else Exit Sub End If objWshShell.Popup "DF status: " & intDFstatus,6, "Arturo Castaneda" 'Inform user End Sub ' =========== SUBRUTINE: FREEZEIT =============== Sub FREEZEIT If Frozen = True Then Exit Sub Else objWshShell.Run(strUNCPath & "DFC6 5aa16 /BOOTFROZEN") End If End Sub ' ********** DEEP FREEZE FROZEN? ********** Function Frozen ' Checks to see if Deep Freeze is Frozen and returns True or False. intDFstatus = objWshShell.Run(strUNCPath & "DFC6 5aa16 /ISFROZEN", 1, True) If intDFstatus = 0 Then 'DF is Thawed Frozen = False Else If intDFstatus = 1 Then 'DF is Frozen Frozen = True Else 'A number of other reasons. End If End If End Function ' You cannot define a Function procedure inside any other procedure (for example, Sub or Property Get). ' http://msdn.microsoft.com/en-us/library/x7hbf8fa(VS.85).aspx Function isException(byval accname) ' Add accounts you do NOT want to delete select case accname case "Administrator" isException = True case "ASPNET" isException = True case "Guest" isException = True case "HelpAssistant" isException = True case sophosaccount ' variable compoused of text + the computer name + text isException = True case adminacc2 ' variable used because account contains a minus sign. isException = True case "sopadmin" isException = True case Else isException = False End Select End Function Function fldrException(byval fldrname) select case fldrname case "All Users" fldrException = True case "Default User" fldrException = True case "LocalService" fldrException = True case "NetworkService" fldrException = True case "Administrator" fldrException = True case "sopadmin" fldrException = True case "Copy of Default User" fldrException = True case Else fldrException = False End Select End Function '******* Function RegistryKeyExists ***** '* Returns a value (true / false) 'This function checks to see if a passed registry key exists, and 'returns true if it does or false id it does NOT. 'Requirements: The registry key you are looking for (RegistryKey) 'Note: RegistryKey MUST end in a backslash (\), or FALSE will be returned Function RegistryKeyExists (RegistryKey) 'Ensure the last character is a backslash (\) - if it isn't, we aren't looking for a key If (Right(RegistryKey, 1) <> "\") Then 'It's not a registry key we are looking for RegistryKeyExists = false Else On Error Resume Next 'If there isnt the key when we read it, it will return an error, so we need to resume objWshShell.RegRead RegistryKey 'Try reading the key If Err <> 0 Then RegistryKeyExists = False Else RegistryKeyExists = True End If 'Turn error reporting back on On Error Goto 0 End If End Function