sammy2ooo 10 Geschrieben 24. April 2008 Melden Geschrieben 24. April 2008 Ich versuche per VBscript ein paar Registry Werte zu löschen, dazu habe ich folgendes geschrieben: Dim shell, result Set Shell = CreateObject("Wscript.Shell") On Error Resume Next result = Shell.RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Shared Tools\Proofing Tools\TCSC translator\") On Error GoTo 0 If result <> 0 Then cscript.echo "Error while trying to delete HKEY_CURRENT_USER\Software\Microsoft\Shared Tools\Proofing Tools\TCSC translator\" End If result = Shell.RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Shared Tools\Proofing Tools\Grammar\MSGrammar\3.0\1033") On Error GoTo 0 If result <> 0 Then cscript.echo "Error while trying to delete HKEY_CURRENT_USER\Software\Microsoft\Shared Tools\Proofing Tools\Grammar\MSGrammar\3.0\1033\" End If result = Shell.RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Shared Tools\Proofing Tools\1.0\Office\") On Error GoTo 0 If resulut <> 0 Then cscript.echo "Error while trying to delete HKEY_CURRENT_USER\Software\Microsoft\Shared Tools\Proofing Tools\1.0\Office\" End If result = Shell.RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Shared Tools\Proofing Tools\1.0\Override\") On Error GoTo 0 If result <> 0 Then cscript.echo "Error while trying to delete HKEY_CURRENT_USER\Software\Microsoft\Shared Tools\Proofing Tools\1.0\Override\" End If result = Shell.RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Shared Tools\Proofing Tools\1.0\Custom Dictionaries\1_state") On Error GoTo 0 If result <> 0 Then cscript.echo "Error while trying to delete HKEY_CURRENT_USER\Software\Microsoft\Shared Tools\Proofing Tools\1.0\Custom Dictionaries\1_state" End If CScript.Echo "Done!" Allerdings erhalte ich bei der Ausführung immer: H:\Scripts\prod\fixProofingTools.vbs(26, 1) WshShell.RegDelete: Unable to remove registry key "HKEY_CURRENT_USER\Software\Microsoft\Shared Tools\Proofing Tools\Grammar\MSGrammar\3.0\1033". Wenn ich mit regedit die Berechtigungen kontrolliere, sehe ich das der Benutzer mit dem ich das Script ausführe "Full control" vererbt bekommen hat... Administrators: Full Control, Read (alles veerbt von oben)Mein User: Full Control, Read (alles vererbt von oben) Restricted: Read (veerbt) System: Full Control, Read (vererbt) Kann mir das jemand erklären? :confused:
sammy2ooo 10 Geschrieben 24. April 2008 Autor Melden Geschrieben 24. April 2008 Okay, dann habe ich das noch gefunden: The RegDelete method of Windows Script Host cannot delete keys that contain subkeys ...und dementsprechend mein Script angepasst, schön und gut, funktioniert trotzdem nicht :suspect: Const HKEY_CLASSES_ROOT = &H80000000 Const HKEY_CURRENT_USER = &H80000001 Const HKEY_LOCAL_MACHINE = &H80000002 Const HKEY_USERS = &H80000003 ' Object used to get StdRegProv Namespace Set wmiLocator = CreateObject("WbemScripting.SWbemLocator") ' Object used to determine local machine name Set wshNetwork = CreateObject("WScript.Network") ' Registry Provider (StdRegProv) lives in root\default namespace. Set wmiNameSpace = wmiLocator.ConnectServer(wshNetwork.ComputerName, "root\default") Set objRegistry = wmiNameSpace.Get("StdRegProv") ' Example Deletion of Value sPath1 = "Software\Microsoft\Shared Tools\Proofing Tools\TCSC translator" sPath2 = "Software\Microsoft\Shared Tools\Proofing Tools\Grammar\MSGrammar\3.0\1033" sPath3 = "Software\Microsoft\Shared Tools\Proofing Tools\1.0\Office" sPath4 = "Software\Microsoft\Shared Tools\Proofing Tools\1.0\Override" sPath5 = "Software\Microsoft\Shared Tools\Proofing Tools\1.0\Custom Dictionaries\1_state" lRC = DeleteRegEntry(HKEY_CURRENT_USER, sPath1) lRC = DeleteRegEntry(HKEY_CURRENT_USER, sPath2) lRC = DeleteRegEntry(HKEY_CURRENT_USER, sPath3) lRC = DeleteRegEntry(HKEY_CURRENT_USER, sPath4) lRC = DeleteRegEntry(HKEY_CURRENT_USER, sPath5) wScript.Echo "Done!" Function DeleteRegEntry(sHive, sEnumPath) ' Attempt to delete key. If it fails, start the subkey ' enumration process. lRC = objRegistry.DeleteKey(sHive, sEnumPath) ' The deletion failed, start deleting subkeys. If (lRC <> 0) Then ' Subkey Enumerator On Error Resume Next lRC = objRegistry.EnumKey(HKEY_LOCAL_MACHINE, sEnumPath, sNames) For Each sKeyName In sNames If Err.Number <> 0 Then Exit For lRC = DeleteRegEntry(sHive, sEnumPath & "\" & sKeyName) Next On Error Goto 0 ' At this point we should have looped through all subkeys, trying ' to delete the registry key again. lRC = objRegistry.DeleteKey(sHive, sEnumPath) End If End Function –
sammy2ooo 10 Geschrieben 24. April 2008 Autor Melden Geschrieben 24. April 2008 Und noch ein Ansatz der nicht funktioniert :suspect: Const HKEY_CLASSES_ROOT = &H80000000 Const HKEY_CURRENT_USER = &H80000001 Const HKEY_LOCAL_MACHINE = &H80000002 Const HKEY_USERS = &H80000003 ' Object used to get StdRegProv Namespace Set wmiLocator = CreateObject("WbemScripting.SWbemLocator") ' Object used to determine local machine name Set wshNetwork = CreateObject("WScript.Network") ' Registry Provider (StdRegProv) lives in root\default namespace. Set wmiNameSpace = wmiLocator.ConnectServer(wshNetwork.ComputerName, "root\default") Set objRegistry = wmiNameSpace.Get("StdRegProv") ' Enumerate the users SID mySID = getSID() ' Constract the values sPath1 = mySID & "\Software\Microsoft\Shared Tools\Proofing Tools\TCSC translator\" sPath2 = mySID & "\Software\Microsoft\Shared Tools\Proofing Tools\Grammar\MSGrammar\3.0\1033\" sPath3 = mySID & "\Software\Microsoft\Shared Tools\Proofing Tools\1.0\Office\" sPath4 = mySID & "\Software\Microsoft\Shared Tools\Proofing Tools\1.0\Override\" sPath5 = mySID & "\Software\Microsoft\Shared Tools\Proofing Tools\1.0\Custom Dictionaries\1_state" ' lRC = DeleteRegEntry(HKEY_USERS, sPath1) lRC = DeleteRegEntry(HKEY_USERS, sPath2) ' lRC = DeleteRegEntry(HKEY_USERS, sPath3) ' lRC = DeleteRegEntry(HKEY_USERS, sPath4) ' lRC = DeleteRegEntry(HKEY_USERS, sPath5) wScript.Echo "Done!" Function DeleteRegEntry(sHive, sEnumPath) ' Attempt to delete key. If it fails, start the subkey ' enumration process. lRC = objRegistry.DeleteKey(sHive, sEnumPath) ' The deletion failed, start deleting subkeys. If (lRC <> 0) Then ' Subkey Enumerator On Error Resume Next lRC = objRegistry.EnumKey(HKEY_LOCAL_MACHINE, sEnumPath, sNames) For Each sKeyName In sNames If Err.Number <> 0 Then Exit For lRC = DeleteRegEntry(sHive, sEnumPath & "\" & sKeyName) Next On Error Goto 0 ' At this point we should have looped through all subkeys, trying ' to delete the registry key again. lRC = objRegistry.DeleteKey(sHive, sEnumPath) End If End Function Function getSID() Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") oReg.EnumKey HKEY_CURRENT_USER, "Software\Microsoft\Protected Storage System Provider", arrSubKeys For Each subkey In arrSubKeys getSID = subkey Next End Function – Habe die Lösung mittlerweile selber gefunden: Schuld war eine Gruppenrichtlinie "Prevent Access to Registry Editing Tools" :rolleyes: Und hier eine etwas einfacherer Lösung wie die vorhergehenden Scripts: regedit /s fixProofingTools.reg Windows Registry Editor Version 5.00 [-HKEY_CURRENT_USER\Software\Microsoft\Shared Tools\Proofing Tools]
blub 115 Geschrieben 25. April 2008 Melden Geschrieben 25. April 2008 Hallo, wenn du mal die Powershell probieren möchtest, da wirds ein übersichtlicher Einzeiler: Remove-item "hkcu:\\Software\Microsoft\Shared Tools\Proofing Tools" -recurse cu blub
Empfohlene Beiträge
Erstelle ein Benutzerkonto oder melde dich an, um zu kommentieren
Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können
Benutzerkonto erstellen
Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!
Neues Benutzerkonto erstellenAnmelden
Du hast bereits ein Benutzerkonto? Melde dich hier an.
Jetzt anmelden