Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Const HKLM = &h80000002
- Const HKCU = &H80000001
- Const DELETE = &h10000
- Set sh = WScript.CreateObject("Wscript.Shell")
- Set objShell = CreateObject("Shell.Application")
- repAppData = sh.ExpandEnvironmentStrings("%localappdata%")
- repTemp = sh.ExpandEnvironmentStrings("%TEMP%")
- repWindows = sh.ExpandEnvironmentStrings("%WINDIR%")
- strComputer = sh.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
- Const HotFixID = "3035583"
- kbURLxWin7x32 = "https://download.microsoft.com/download/C/5/3/C530B84C-857A-4296-BB9E-3BB59EEDF555/Windows6.1-KB3065987-v2-x86.msu"
- kbURLxWin7x64 = "https://download.microsoft.com/download/F/6/7/F678BB18-7D81-4BBA-8FED-6388FF7968AD/Windows6.1-KB3065987-v2-x64.msu"
- kbURLxWin8x32 = "https://download.microsoft.com/download/C/4/3/C43C4D83-A249-4026-9A36-1EB796957FA0/Windows8.1-KB3065988-v2-x86.msu"
- kbURLxWin8x64 = "https://download.microsoft.com/download/F/3/D/F3D9A5A4-75A3-47C8-971E-9D0D09AAF9DC/Windows8.1-KB3065988-v2-x64.msu"
- kbNamexWin7x32 = "Windows6.1-KB3065987-v2-x86.msu"
- kbNamexWin7x64 = "Windows6.1-KB3065987-v2-x64.msu"
- kbNamexWin8x32 = "Windows8.1-KB3065988-v2-x86.msu"
- kbNamexWin8x64 = "Windows8.1-KB3065988-v2-x64.msu"
- Set reg = GetObject("winmgmts://./root/default:StdRegProv")
- reg.CheckAccess HKLM, "SYSTEM\CurrentControlSet", DELETE, isAdmin
- If Not isAdmin Then
- ' Si les privileges ne sont pas eleves
- If WScript.Arguments.Count = 0 Then
- ' Ouverture du script avec elevation de privileges
- CreateObject("Shell.Application").ShellExecute WScript.FullName, _
- Chr(34) & WScript.ScriptFullName & Chr(34) & " uac", _
- sh.CurrentDirectory, "runas", 1
- WScript.Quit 0
- Else
- WScript.Echo "Privilege elevation failed!"
- WScript.Quit 1
- End If
- Else
- 'Prerequis detection et unstallation KB3035583
- HFStatus = CheckHotfixStatus(strComputer, HotFixID)
- If HFStatus = False Then
- sh.Popup "Le poste ne semble pas necessiter de manipulation", 30, "Fin du script"
- Else
- '0 creation point restauration systeme
- createRestorePoint
- '1 desinstallation du kb en mode non silencieux
- sh.run "taskkill /f /t /im gwx.exe"
- strCmd = "wusa.exe /kb:3035583 /uninstall"
- ReturnCode = ObjShell.Run(strCmd, 8, true)
- If ReturnCode = 0 then
- sh.Popup "Desinstallation de la mise a jour : Ok.", 5, "Desinstallation de mise a jour"
- Else
- 'Error
- sh.Popup "Desinstallation de la mise a jour : Erreur (Arret imminent du script)", 30, "Desinstallation de mise a jour"
- wscript.quit
- End If
- '2 on supprime le package du disque et les reps GWX
- arrRepToDelete = Array(_
- repWindows & "\system32\GWX", _
- repWindows & "\syswow64\GWX", _
- repAppData & "\GWX")
- For Each RepToDelete In arrRepToDelete
- sh.run "Takeown /F " & RepToDelete & " /r"
- sh.run "icacls " & RepToDelete & " /t /grant Administrateur:F"
- sh.run "rmdir /s /q " & RepToDelete & "\"
- Next
- strFilesToDelete = repWindows & "\servicing\packages\*KB3035583*.*"
- sh.run "Takeown /F " & strFilesToDelete
- sh.run "icacls " & strFilesToDelete & " /grant Administrateur:F"
- sh.run "del " & strFilesToDelete
- sh.Popup "Suppression des dossiers de GWX terminee", 5, "Nettoyage de GWX"
- '3 on bloque avec une policie la réinstallation de cette update
- strCurrentOSVersion = CheckLocalOSVersion
- Select Case strCurrentOSVersion
- Case "1" 'Win7 - 32bits
- dlMyFile kbURLxWin7x32, kbNamexWin7x32
- ObjShell.Run "wusa.exe " & repTemp & "\" & kbNamexWin7x32
- Case "2" 'windows 7 64 bit
- dlMyFile kbURLxWin7x64, kbNamexWin7x64
- ObjShell.Run "wusa.exe " & repTemp & "\" & kbNamexWin7x64
- Case "3" 'windows 81 32 bit
- dlMyFile kbURLxWin8x32, kbNamexWin8x32
- ObjShell.Run "wusa.exe " & repTemp & "\" & kbNamexWin8x32
- Case "4" 'windows 81 64 bit
- dlMyFile kbURLxWin8x64, kbNamexWin8x64
- ObjShell.Run "wusa.exe " & repTemp & "\" & kbNamexWin8x64
- Case "5" 'inconnu
- End Select
- '4 on bloque l icone en bas
- DelGWXIcon
- '5 on supprime les taches planifiees GWX
- strRepToAlter = repWindows & "\System32\Tasks\Microsoft\Windows\Setup\GWXTriggers"
- ObjShell.Run "takeown /f " & strRepToModify & " /r"
- ObjShell.Run "icacls " & strRepToModify & " /t /grant Administrateur:F"
- arrGWXAndGWXTriggersTasks = Array(_
- "gwx\launchtrayprocess", _
- "gwx\refreshgwxconfig", _
- "gwx\refreshgwxconfigandcontent", _
- "gwx\refreshgwxcontent", _
- "GWXTriggers\Logon-5d", _
- "GWXTriggers\MachineUnlock-5d", _
- "GWXTriggers\OutOfIdle-5d", _
- "GWXTriggers\OutOfSleep-5d", _
- "GWXTriggers\refreshgwxconfig-B", _
- "GWXTriggers\ScheduleUpgradeReminderTime", _
- "GWXTriggers\ScheduleUpgradeTime", _
- "GWXTriggers\Time-5d")
- For Each strTask In arrGWXAndGWXTriggersTasks
- ObjShell.Run "schtasks /DELETE /TN Microsoft\Windows\Setup\" & strTask & " /F"
- Next
- sh.Popup "La mise a jour vers Windows 10 est maintenant desactivee !", 30, "Fin du script"
- End If
- End If
- Sub dlMyFile(myURL,myKbName)
- dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP")
- dim bStrm: Set bStrm = createobject("Adodb.Stream")
- xHttp.Open "GET", myURL, False
- xHttp.Send
- with bStrm
- .type = 1 '//binary
- .open
- .write xHttp.responseBody
- .savetofile repTemp & "\" & myKbName, 2 '//overwrite
- end with
- sh.Popup "Telechargement du patch termine", 5, "Telechargement"
- End Sub
- Sub createRestorePoint
- GetObject("winmgmts:\\.\root\default:Systemrestore").CreateRestorePoint "Avant desactivation de la mise a jour Windows 10", 0, 100
- sh.Popup "Cree avec succes", 5, "Point de restauration Windows"
- Exit Sub
- End Sub
- Function CheckHotfixStatus(strComputer, strHotfixID)
- Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
- if err.number <> 0 then
- CheckParticularHotfix = "Impossible de se connecter au WMI"
- exit function 'No reason to continue
- end if
- strWMIforesp = "Select * from Win32_QuickFixEngineering where HotFixID = 'Q" & strHotfixID & "' OR HotFixID = 'KB" & strHotfixID & "'"
- Set colQuickFixes = objWMIService.ExecQuery (strWMIforesp)
- if err.number <> 0 Then 'if an error occurs
- CheckParticularHotfix = "Impossible de trouver les informations WMI de cet Hotfix"
- else 'Error number 0 meaning no error occured
- tal = colQuickFixes.count
- if tal > 0 then
- CheckParticularHotfix = True 'HF installed
- else
- CheckParticularHotfix = False 'HF not installed
- end If
- end if
- Set colQuickFixes = Nothing
- Err.Clear
- On Error GoTo 0
- End Function
- Function CheckLocalOSVersion
- Dim OSVer, verbits
- OSVer = sh.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion")
- verbits = sh.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
- if OSVer = "6.1" AND verbits = "x86" then
- CheckLocalOSVersion = 1 'win7 32 bit
- Elseif OSVer = "6.1" AND verbits = "AMD64" then
- CheckLocalOSVersion = 2 'win7 64 bit
- Elseif OSVer = "6.3" AND verbits = "x86" then
- CheckLocalOSVersion = 3 'win81 32 bit
- Elseif OSVer = "6.3" AND verbits = "AMD64" then
- CheckLocalOSVersion = 4 'win81 64 bit
- else
- wscript.Echo "os inconnu"
- CheckLocalOSVersion = 5 'inconnu
- end If
- End Function
- Sub DelGWXIcon
- Dim RegLocate, RegLocate1
- RegLocate = "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\GWX\DisableGwx"
- sh.RegWrite RegLocate,"1","REG_DWORD"
- RegLocate1 = "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\DisableOSUpgrade"
- sh.RegWrite RegLocate1,"1","REG_DWORD"
- Exit Sub
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement