...
Well, I had it, but it gave me an idea, what is happening in the script.
When I debugged it, I found, that it was able to add the new key to every USER, except one, where it failed.
In my haste, I've forgotten that even the administrator is lower then the "SYSTEM" account, so chances are it crashes there.
I will add some error handling into the area where it loops through each one:
Sub SetKeysForMachine(Byval MachineName)
const HKEY_USERS = &H80000003
strComputer = MachineName
Set StdOut = WScript.StdOut
stdout.WriteLine "Connecting to " & machineName
'Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
'MachineName & "\root\default:StdRegProv")
set oReg = GetObject("WinMgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/default:stdRegProv")
strKeyPath = ""
oReg.EnumKey HKEY_USERS, strKeyPath, arrSubKeys
On Error Resume Next
For Each subkey In arrSubKeys
Err.clear
'StdOut.WriteLine subkey
'save subkey\Control Panel\Desktop value, screensaveactive.
strKeyPath = subkey & "\Control Panel\Desktop"
strValueName = "ScreenSaveActive"
strValue = "1"
oReg.SetStringValue HKEY_USERS,strKeyPath,strValueName,strValue
'Next line was changed:
oReg.SetValue KEY_USERS, strkeypath, "SCRNSAVE.EXE", REG_EXPAND_SZ, """%SystemRoot%\System32\ITEP SS_UTI Version.scr"""
If Err <> 0 then
stdout.WriteLine "Failed to change key " + strkeypath + " on machine " + Strcomputer
stdout.WriteLine "error was " + ERROR
end if
Next
End Sub
Dim mmachineNames()
Const NumMachines =1
redim mmachinenames(NumMachines-1)
'Change this portion, to reflect the actual number of machines (the above constant) as well as their names.
'mmachinenames(0) = "." 'this reflects the local machine. This was for my testing, change it :P
mmachinenames(0) = "Satellite"
on error resume next
Dim I ,X
'for each machine in mmachinenames
For I = 0 to ubound(mmachinenames)
SetKeysForMachine mmachinenames(I)
if err <> 0 then
wScript.stdOut.WriteLine "Error processing machine, " & mmachinenames(I) & "Error:" & ERR
Else
X=X+1
end if
next
wScript.stdOut.WriteLine "Script finished. Successfully processed " & Val(X) & " of " & ubound(mmachinenames)+1 & " Machines."
Now, were the previous one, if it encountered an error, went back to the main procedure and complained to you, this one will continue on through the loop. It still complains though, and even more loudly!