lexapass
Full Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору ' This script is provided without warranty. ' ########################################################################### ' ### HotFix-VBScript for Microsoft Security Update KB2686509 V1.33 ### ' ###---------------------------------------------------------------------### ' ### (C) 2012 Christian Schumm, North Rhine-Westphalia, Germany ### ' ########################################################################### ' ### There are two different problems for running the KB2686509. ### ' ###---------------------------------------------------------------------### ' ### 1. Entry Scancode Map in ### ' ### HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layout ### ' ### ### ' ### This entry changes the keycodes - i.e. if you have switched your ### ' ### CapsLock key to any thing else or disabled it. It seems KB2686509 ### ' ### fails with this entry, so if found by the script it will be deleted ### ' ### You can restore this key by double clicking the export file ### ' ### HKLM_KBLayout_YYYMMDD-hhmmss.reg ### ' ### located in the path where you started HotFix4KB2686509 ### ' ### ### ' ###---------------------------------------------------------------------### ' ### ### ' ### 2. Keyboard Layout Keys under ### ' ### HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layouts ### ' ### ### ' ### If you or your systembuilder have unchecked some keyboard layouts ### ' ### at the installation process, these files were not copied. Actually ### ' ### their registry key entries including the file informations were ### ' ### written. The KB2686509 doesn't like these entries and fails. ### ' ### The script checks every layout entry and if the file doesn't exist ### ' ### deletes the key. ### ' ### You can restore these keys by double clicking the export file ### ' ### HKLM_KBLayouts_YYYMMDD-hhmmss.reg ### ' ### located in the path where you started HotFix4KB2686509 ### ' ### ### ' ###---------------------------------------------------------------------### ' ### ### ' ### I hope this script will help you, if you retrieve the message ### ' ### "NO CHANGES HAVE BEEN MADE - NO KNOWN ERRORS FOUND!" ### ' ### you have to wait on Microsoft for solving their problems. ### ' ### ### ' ### Best wishes, Christian. 2012/05/15 ### ' ########################################################################### ' >>> <<< ' >>> RUN THIS SCRIPT: cscript HotFix4KB2686509.vbs <<< ' >>> <<< ' ########################################################################### Option Explicit Const KEY_QUERY_VALUE = &H0001 Const DELETE = &H00010000 Const HKEY_LOCAL_MACHINE = &H80000002 Dim StdOut, WshShell, objReg, objFSO, bolEpicFail Set StdOut = WScript.StdOut Set WshShell = WScript.CreateObject("WScript.Shell") Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_ ".\root\default:StdRegProv") Set objFSO = CreateObject("Scripting.FileSystemObject") bolEpicFail = False ' ############# Main ' ############# StdOut.WriteBlankLines(3) If (bolEpicFail) Then StdOut.WriteLine "Changes have been done - try to run KB2686509 again!" Else StdOut.WriteLine "NO CHANGES HAVE BEEN MADE - NO KNOWN ERRORS FOUND!" End If Set objFSO = Nothing Set objReg = Nothing Set WshShell = Nothing Set StdOut = Nothing ' ########################################################################### Sub Main ' ########################################################################### Dim strKeyPath, strValueName, varRetValue, arrSubKeys, strSubKey,_ strPathSystem32, strLayoutFile strKeyPath = "SYSTEM\CurrentControlSet\Control\Keyboard Layout" StdOut.WriteBlankLines(3) ' ### check rights ### If (Not HaveRights(strKeyPath)) Or (Not HaveRights(strKeyPath & "s")) Then StdOut.WriteLine "Insufficent rights, please logon as an administrator." Exit Sub End If StdOut.WriteLine "===================" & vbCrLf & "= Registry Backup =" &_ vbCrLf & "===================" ' ### backup registry ### If (Not SaveRegistry("HKLM_KBLayout",_ "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout")) Then Exit Sub End If If (Not SaveRegistry("HKLM_KBLayouts",_ "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts")) Then Exit Sub End If StdOut.WriteLine vbCrLf & "===================" & vbCrLf ' ###################################################################### ' ############### PART ONE Keyboard Layout\Scancode Map ############### ' ###################################################################### ' ### delete ' HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layout\Scancode Map strValueName = "Scancode Map" varRetValue = objReg.DeleteValue(HKEY_LOCAL_MACHINE,strKeyPath,strValueName) StdOut.WriteLine "HKLM\" & strKeyPath & "\" & strValueName If (varRetValue = 0) And (Err.Number = 0) Then bolEpicFail = true StdOut.WriteLine " has been deleted." Else StdOut.WriteLine " not found." End If StdOut.WriteLine vbCrLf & "===================" & vbCrLf ' ###################################################################### ' ##################### PART TWO Keyboard Layouts ##################### ' ###################################################################### strKeyPath = "SYSTEM\CurrentControlSet\Control\Keyboard Layouts" strPathSystem32 = WshShell.ExpandEnvironmentStrings("%systemroot%")_ & "\System32\" objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys StdOut.WriteLine "Layout File" ' Check every entry if file exists in %SYSTEMROOT%\System32 For Each strSubKey In arrSubKeys varRetValue = objReg.GetStringValue(HKEY_LOCAL_MACHINE, _ strKeyPath & "\" & strSubKey,"Layout File",strLayoutFile) If (varRetValue = 0) And (Err.Number = 0) Then StdOut.Write strSubKey & " " & Left(strLayoutFile & Space(21),21) strLayoutFile = strPathSystem32 & strLayoutFile varRetValue = true If (objFSO.FileExists(strLayOutFile)) Then StdOut.WriteLine "File exists" varRetValue = false Else StdOut.Write "File not found" End If Else StdOut.Write strSubKey & "\Layout File entry not found" End If ' delete this key If (varRetValue) Then bolEpicFail = true StdOut.Write " - Key " varRetValue = objReg.DeleteKey(HKEY_LOCAL_MACHINE, _ strKeyPath & "\" & strSubKey) If (varRetValue = 0) And (Err.Number = 0) Then StdOut.Write "has" Else StdOut.Write "COULD NOT" End If StdOut.WriteLine " been deleted." End If Next End Sub 'Main ' ######################################################################### Function HaveRights( strKeyPath ) ' Access? objReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_QUERY_VALUE, HaveRights ' Delete? If (HaveRights) Then objReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, DELETE, HaveRights End If End Function 'HaveRights ' ------------------------------------------------------------------------- Function SaveRegistry( strFileName, strPath) strFileName = """.\" & strFileName & "_" & serialNow() & ".reg"" " SaveRegistry = WshShell.Run(_ "regedit /e " & strFileName & Chr(34) & strPath & Chr(34), 0, TRUE) If (SaveRegistry <> 0) Then StdOut.WriteLine "Error " & SaveRegistry & " writing " & strFileName SaveRegistry = False Else StdOut.WriteLine strPath & vbCrLf &" to " & strFileName SaveRegistry = True End If End Function 'SaveRegistry ' ------------------------------------------------------------------------- Function serialNow() serialNow = Year(Now) & Right("0"&Month(Now),2) & Right(Day(Now),2) & "-" &_ Replace(TimeValue(Now), ":", "") End Function 'serialNow | Всего записей: 566 | Зарегистр. 11-10-2004 | Отправлено: 21:47 16-05-2017 | Исправлено: lexapass, 21:51 16-05-2017 |
|