Avatar of tbkurtz
tbkurtz
Flag for United States of America

asked on 

Problem with VB Script - Loop

The following code has to be run twice in order to disable both keys.

I will post the batch file it is being called from in a second post.
dim strComputer, arrKeyPaths, strValueName, strValue
arrKeyPaths = Array(_
        "SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control\User Settings",_
        "SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control")
strKey="Permission Required"
 
' Read computer name from argument supplied - if no argument, assume local machine
if WScript.Arguments.Count<1 then
        strComputer="."
else
        strComputer=WScript.Arguments(0)
end if
 
Const HKEY_LOCAL_MACHINE = &H80000002
dim oReg: Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
 
for i=0 to UBound(arrKeyPaths)
        oReg.SetDWORDValue HKEY_LOCAL_MACHINE,arrKeyPaths(i),strKey,1
next

Open in new window

VB ScriptWindows Batch

Avatar of undefined
Last Comment
tbkurtz

8/22/2022 - Mon