Does anyone have a simple script that will delete all keys (folders) in the below registry location please?
Sorry i missed some out
I would like a script that will delete all keys in the above area but only when a server replies to a ping.
Also i dont want the connections key deleting just the ones under that.
Sorry to mess you around
Last edited by FN-GM; 26th August 2010 at 09:34 PM.
As an alturnative to a ping, which I never got working properly in VB script for some reason, create a single hidden read only share on the server with just a txt file in it, then you can simply use an "if file exists" statement with the full UNC path to see if the script can see the share, and thus the server - I use this to determine whether a member of staffs laptop is on the school network or not when they logon, and thus change the proxy settings accordingly.
Last edited by maniac; 27th August 2010 at 12:18 AM.
For now i am using the below script to delete the subkeys only. But it doesnt work. Can anyone see why please?
Code:On Error Resume Next Const HKEY_LOCAL_MACHINE = &H80000001 strComputer = "." strKeyPath = "SYSTEM\CurrentControlSet\Control\Print\Connections" Set objRegistry = GetObject("winmgmts:\\" & _ strComputer & "\root\default:StdRegProv") DeleteSubkeys HKEY_LOCAL_MACHINE, strKeypath Sub DeleteSubkeys(HKEY_LOCAL_MACHINE, strKeyPath) objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys If IsArray(arrSubkeys) Then For Each strSubkey In arrSubkeys DeleteSubkeys HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubkey Next End If ' objRegistry.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath End Sub
Have you taken the 'on error resume next' statement out and seen what errors it produces?
It doesn't work because you've commented out the line which makes it work ...
What it's doing is recursively calling the DeleteSubkeys routine and you need that last line otherwise it won't delete the low level keys.
I think you could do:
but try this on a sacrificial machine first!Code:if strKeyPath<>"SYSTEM\CurrentControlSet\Control\Print\Connections" then objRegistry.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath end if
There are currently 1 users browsing this thread. (0 members and 1 guests)