Set Shell = WScript.CreateObject("WScript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") Const ForReading = 1, _ ForWriting = 2, _ ForAppending = 8, _ OKButton = 0, _ Critical = 16, _ Question = 32, _ ExclamIcon = 48, _ Info = 64, _ CreateFile = "True" const HKEY_LOCAL_MACHINE = &H80000002 const REG_SZ = 1 const REG_EXPAND_SZ = 2 const REG_BINARY = 3 const REG_DWORD = 4 const REG_MULTI_SZ = 7 strEnv = Shell.ExpandEnvironmentStrings("%temp%") strPrgFls = Shell.ExpandEnvironmentStrings("%ProgramFiles%") windir = Shell.ExpandEnvironmentStrings("%windir%") progdata = Shell.ExpandEnvironmentStrings("%ProgramData%") appdata = Shell.ExpandEnvironmentStrings("%APPDATA%") userprofile= Shell.ExpandEnvironmentStrings("%USERPROFILE%") alluserprofile = Shell.ExpandEnvironmentStrings("%ALLUSERSPROFILE%") if progdata = "%ProgramData%" then progdata = alluserprofile & Replace(appdata, userprofile, "") WinTitle = "MSSE deployment script" Shell.Regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\HideFileExt", 0, "REG_DWORD" if CStr(CheckRegKey("HKLM\Software\Microsoft\Windows NT\CurrentVersion\CurrentVersion")) then if CStr(Shell.RegRead("HKLM\Software\Microsoft\Windows NT\CurrentVersion\CurrentVersion")) = "5.0" then BtnCode = Shell.Popup( "This script is not supported for Windows 2000", 0, WinTitle, 16) WScript.Quit end if if CStr(Shell.RegRead("HKLM\Software\Microsoft\Windows NT\CurrentVersion\CurrentVersion")) = "6.2" then BtnCode = Shell.Popup( "This script is not supported for Windows 8", 0, WinTitle, 16) WScript.Quit end if end if Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Set colSoftware = objWMIService.ExecQuery ("Select * from Win32_Product")' DI_Installed = false For Each objSoftware in colSoftware if InStr(LCase(objSoftware.Caption), "microsoft security client") <> 0 then BtnCode = Shell.Popup("The MS Essentials should not be presented at the time of running this script", 0, WinTitle, Critical) WScript.Quit end if if InStr(LCase(objSoftware.Caption), "data igloo") <> 0 then DI_Installed = true Next if not DI_Installed then BtnCode = Shell.Popup("Faronics Data Igloo is not installed", 0, WinTitle, Critical) WScript.Quit end if if not objFSO.FileExists(windir & "\System32\IGC.exe") then BtnCode = Shell.Popup("IGC utility is not found. This can be due to the older version of Data Igloo installed. Please, update Data Igloo.", 0, WinTitle, Critical) WScript.Quit end if if CStr(CheckRegKey("HKLM\Software\Faronics\Deep Freeze 6\DF Status")) then DFStatus = Shell.RegRead ("HKLM\Software\Faronics\Deep Freeze 6\DF Status") else if CStr(CheckRegKey("HKLM\Software\Wow6432Node\Faronics\Deep Freeze 6\DF Status")) then DFStatus = Shell.RegRead ("HKLM\Software\Wow6432Node\Faronics\Deep Freeze 6\DF Status") else DFStatus = "Not Installed" end if end if if DFStatus = "Frozen" then BtnCode = Shell.Popup("Deep Freeze is currently Frozen. Please, reboot into Thawed state in order to run this script.", 0, WinTitle, Critical) WScript.Quit end if if (WScript.Arguments.Count > 0) Then RedirectionPath = WScript.Arguments(0) else RedirectionPath = InputBox("Enter the folder name on Thawed location: ", WinTitle) end if if not objFSO.FolderExists(RedirectionPath) then On Error Resume next objFSO.CreateFolder RedirectionPath if not objFSO.FolderExists(RedirectionPath) then BtnCode = Shell.Popup("The specified folder cannot be created", 0, WinTitle, Critical) WScript.Quit end if end if Set curFolder = objFSO.GetFolder(RedirectionPath) 'All verifications have passed VB_CreateFolder(strPrgFls & "\Microsoft Security Client") VB_CreateFolder(progdata & "\Microsoft\Microsoft Security Client") VB_CreateFolder(progdata & "\Microsoft\Microsoft Antimalware") VB_CreateFolder(RedirectionPath & "\Microsoft Security Client1") VB_CreateFolder(RedirectionPath & "\Microsoft Security Client2") VB_CreateFolder(RedirectionPath & "\Microsoft Antimalware") Shell.Run "IGC /RedirectFolder """ & strPrgFls & "\Microsoft Security Client"" /loc:""" & RedirectionPath & "\Microsoft Security Client1""", 0, true Shell.Run "IGC /RedirectFolder """ & progdata & "\Microsoft\Microsoft Security Client"" /loc:""" & RedirectionPath & "\Microsoft Security Client2""", 0, true Shell.Run "IGC /RedirectFolder """ & progdata & "\Microsoft\Microsoft Antimalware"" /loc:""" & RedirectionPath & "\Microsoft Antimalware""", 0, true Shell.Run "%comspec% /c IGC /RedirectFolder > """ & windir & "\temp\~redirlist.txt""", 0, true If Objfso.FileExists(windir & "\temp\~redirlist.txt") then Set ts = Objfso.OpenTextFile(windir & "\temp\~redirlist.txt", 1) folder_count = 0 Do ReadStuff = ts.ReadLine if (Instr(LCase(ReadStuff), LCase(strPrgFls & "\Microsoft Security Client")) <> 0) then folder_count = folder_count + 1 if (Instr(LCase(ReadStuff), LCase(progdata & "\Microsoft\Microsoft Security Client")) <> 0) then folder_count = folder_count + 1 if (Instr(LCase(ReadStuff), LCase(progdata & "\Microsoft\Microsoft Antimalware")) <> 0) then folder_count = folder_count + 1 Loop While (NOT ts.AtEndOfStream) ts.Close else BtnCode = Shell.Popup("Unable to verify redirected folders.", 0, WinTitle, Critical) WScript.Quit end if if folder_count < 3 then BtnCode = Shell.Popup("Some of the MSSE folders failed to redirect. Please, check IGC.log for more details.", 0, WinTitle, Critical) WScript.Quit end if Shell.RegWrite "HKLM\Software\Microsoft\Microsoft Security Client\", "" Shell.RegWrite "HKLM\Software\Microsoft\Microsoft Antimalware\", "" Shell.RegWrite "HKLM\Software\Microsoft\Microsoft Antimalware Setup\", "" if NOT(CheckRegKey("HKLM\Software\Microsoft\Microsoft Security Client\") AND _ CheckRegKey("HKLM\Software\Microsoft\Microsoft Antimalware\") AND _ CheckRegKey("HKLM\Software\Microsoft\Microsoft Security Client\")) then BtnCode = Shell.Popup("Some of the MSSE registry keys failed to create.", 0, WinTitle, Critical) WScript.Quit end if Shell.Run "%comspec% /c IGC /RedirectRegKeyLocation > """ & windir & "\temp\~regloc.txt""", 0, true If Objfso.FileExists(windir & "\temp\~regloc.txt") then Set ts = Objfso.OpenTextFile(windir & "\temp\~regloc.txt", 1) registry_location_set = false Do ReadStuff = ts.ReadLine if (Instr(ReadStuff,strPrgFls & ":\")<>0) then registry_location_set = true Loop While (NOT ts.AtEndOfStream) ts.Close else BtnCode = Shell.Popup("Unable to verify registry Thawed location path.", 0, WinTitle, Critical) WScript.Quit end if if NOT registry_location_set then Shell.Run "IGC /RedirectRegKeyLocation /loc:""" & RedirectionPath & """", 0, true Shell.Run "IGC /RedirectRegKey ""HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft Security Client""" , 0, true Shell.Run "IGC /RedirectRegKey ""HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft Antimalware""" , 0, true Shell.Run "IGC /RedirectRegKey ""HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft Antimalware Setup""", 0, true Shell.Run "%comspec% /c IGC /RedirectRegKey > """ & windir & "\temp\~regkeylist.txt""", 0, true If Objfso.FileExists(windir & "\temp\~regkeylist.txt") then Set ts = Objfso.OpenTextFile(windir & "\temp\~regkeylist.txt", 1) key_count = 0 Do ReadStuff = ts.ReadLine if (Instr(LCase(ReadStuff), LCase("HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft Security Client")) <> 0) then key_count = key_count + 1 if (Instr(LCase(ReadStuff), LCase("HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft Antimalware")) <> 0) then key_count = key_count + 1 if (Instr(LCase(ReadStuff), LCase("HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft Antimalware Setup")) <> 0) then key_count = key_count + 1 Loop While (NOT ts.AtEndOfStream) ts.Close else BtnCode = Shell.Popup("Unable to verify redirected keys.", 0, WinTitle, Critical) WScript.Quit end if if folder_count < 3 then BtnCode = Shell.Popup("Some of the MSSE registries failed to redirect. Please, check IGC.log for more details.", 0, WinTitle, Critical) WScript.Quit end if BtnCode = Shell.Popup("The script has finished successfuly.", 5, WinTitle, Info) 'FUNCTIONS Function VB_CreateFolder(folderpathandname) Set objFSO = CreateObject("Scripting.FileSystemObject") On Error Resume Next objFSO.CreateFolder folderpathandname if not objFSO.FolderExists(folderpathandname) then BtnCode = Shell.Popup("The folder""" & folderpathandname & """ cannot be created", 0, WinTitle, Critical) WScript.Quit end if end Function Function CheckRegKey(sKey) On Error Resume next Shell.RegRead sKey CheckRegKey = (Err.Number = 0) On Error Goto 0 end function Function CheckDrive(Drv) On Error Resume next objFSO.CreateFolder(Drv & "DFTMP") CheckDrive = (Err.Number = 0) On Error Goto 0 On Error Resume next objFSO.DeleteFolder(Drv & "DFTMP") CheckDrive = (Err.Number = 0) On Error Goto 0 End function