0

We need to delete a Security value from CD-ROM drive registry key. The main location is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\IDE. From there it would depend on the make and model of the CD Drive, but there should be a Security value that must be deleted. I found the following VBS code but it doesn’t seem to be working or give an error code:

'****SCRIPT START****
' this script searches for all "security"-keys under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\IDE\ and deletes them
Option Explicit
Const HKEY_LOCAL_MACHINE = &H80000002
Dim oReg : Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
Dim oShell : Set oShell = CreateObject("WScript.Shell")
Dim sPath, aSub, sKey, aSubToo, sKeyToo, dwValue
' Get all keys within sPath
sPath = "SYSTEM\CurrentControlSet\Enum\IDE"
oReg.EnumKey HKEY_LOCAL_MACHINE, sPath, aSub
' Loop through each key
For Each sKey In aSub
    'Get all subkeys within the key 'sKey'
    oReg.EnumKey HKEY_LOCAL_MACHINE, sPath & "\" & sKey, aSubToo
    For Each sKeyToo In aSubToo
        oReg.deleteValue HKEY_LOCAL_MACHINE, sPath & "\" & sKey & "\" & sKeyToo , "Security"
        if Err.Number<>0 then 
            MsgBox Err.Description  ' FOR TESTING ONLY
            Err.Clear
        end if
    Next
Next
'****SCRIPT END****

Upon closer inspection the value can only be deleted by SYSTEM. I need to add the administrator permission full permissions to delete. Not sure if I should continue using VBS or another method to get this done on all the PCs (about 1,000).

Thanks.

6
  • You can use psexec from sysinternals "psexec -s \\RemoteComputer cscript script.vbs" to run as system
    – Zalmy
    Jul 15, 2015 at 2:43
  • When I run the command with the -s argument, it hangs on Windows Script Host. If I view the Task Manager the Microsoft Console Based Script Host (32 bit) is running and stays running even if I pause/break the command.
    – Rick
    Jul 16, 2015 at 13:20
  • Did you consider using GPO preference to delete this key?I
    – Zalmy
    Jul 16, 2015 at 22:14
  • I would also propose GPO if there are not too many different possible names for the key. Otherwise powershell has the ability to modify registry acls. If it has to be vbscript it seems you need to use regini.exe probably
    – Syberdoor
    Jul 17, 2015 at 9:35
  • Not sure how to use GPO Preferences to delete a key name within a varying subkey.
    – Rick
    Jul 17, 2015 at 11:55

0

You must log in to answer this question.

Browse other questions tagged .