從登錄子項中刪除特定值

從登錄子項中刪除特定值

我們需要從 CD-ROM 磁碟機註冊表項中刪除 Security 值。主要位置是HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\IDE。從那裡,它將取決於 CD 驅動器的品牌和型號,但應該有一個必須刪除的安全值。我找到了以下 VBS 代碼,但它似乎不起作用或給出錯誤代碼:

'****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****

仔細檢查後,數值只能由 SYSTEM 刪除。我需要新增管理員權限完全權限才能刪除。不確定我是否應該繼續使用 VBS 或其他方法在所有 PC(大約 1,000 台)上完成此操作。

謝謝。

相關內容