Computer Hope
Microsoft => Microsoft DOS => Topic started by: TheHoFL on June 09, 2009, 04:48:05 PM
-
Hello again...
I have now been given the task of pushing a screen saver to around 25 computers. Then i need to set the screen saver to be he default for all users.
I need to have a folder with a folder labeled "screen_saver" in it.
This is what i have...i know it looks as though a newb wrote it :)
What is does is copy the screensaver file then needs t o set it as the default. I am just having issues with the remote registry part. ???
copy /Y "screen_saver\newSS.scr" "\\timscomputer\c$\windows\System32"
REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V SCRNSAVE.EXE /T REG_SZ /F /D "%SystemRoot%\System32\newSS.scr"
REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V ScreenSaveActive /T REG_SZ /F /D 1
When running that i get the following:
1 file(s) copied.
Press any key to continue . . .
Error: A remote machine was specified, the root key must be HKLM or HKU.
Error: A remote machine was specified, the root key must be HKLM or HKU.
Press any key to continue . . .
Can anyone assist me with this. I cannot find the key in HKLM for the screensaver.
Thank you guys and gals!
-
well im no genious with registry, but the error says :
Error: A remote machine was specified, the root key must be HKLM or HKU.
you have it as:
REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V SCRNSAVE.EXE /T REG_SZ /F /D "%SystemRoot%\System32\newSS.scr"
-
Hmmm.... very true. So i looked in HKU and there is a ".DEFAULT" string. I can drill down and find the keys. However i thought if i made that change there it would only effect the new user profiles that were created and do nothing with the already made user profiles?
-
HKCU is HKEY_CURRENT_USER
HKU is HKEY_USERS
the problem here is that TheHoFL would then need to parse the crud in the HKEY_USERS key, and find out which one corresponds with the current user. (or, perhaps place it in all of them?) (I'm the sole user of my PC, and I have over 10 entries in there!)
really, a better method would be to simply put it in HKEY_LOCAL_MACHINE (HKLM)- or, if possible, simply add a VBScript that will start up for each user, that copies the screensaver from a network drive (perhaps an unmapped share) to the local machine and sets it up locally (where it has access to HKEY_CURRENT_USER).
TO explore why this limitation exists, it seems quite obvious- you can perform remote registry procedures when no user is logged in! In which case, HKEY_CURRENT_USER is undefined. Additionally, it can easily change between calls, if somebody logs off and another logs back off, which can mean that the first half of registry entries go to one, and the second half to another account. Generally not a good thing!
-
I would much rather make the cahnge in HKLM, but i cannot find the string the key would be in, if there is one in there.
-
oh, your right. there isn't one.
what about the idea of running a batch file at logon? and if you already do, it should be a simple change to that script.
-
That would be another excellent idea. I can not do that because we already have a logon.bat that is run at logon that is pushed from our home office location. They will not let us mess with it much. Do you know of any BAT file that could pull the users names and/or change a registry setting for every user profile on a remote computer?
EDIT: I tried remotely setting the regisrty setting in the following location and it did NOT apply to a profile that was already created. It did work when creating a new one though.
\\U1jbennett\HKU\.DEFAULT\Control Panel\Desktop
-
well... it would be possible via VBScript.
But I'm too used to my own registry class in Visual Basic, so I'll have to do a little research on the VBScript methods for changing/enumerating registry data.
Are you able to use VBScript?
-
I suppose i could. VBS is fairly new to me though. So i may ask you some more newbie questions. ;)
-
well, VBScript might be out- because- get this-
it uses WMI, and I believe you recently disabled that?
oh the irony! :P
-
No that was on a different group of computers. :P
-
Oh OK- maybe I can work out something with VBScript then.
-
Thank you so much for your help!
-
OK, here's something to try:
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
'REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V SCRNSAVE.EXE /T REG_SZ /F /D "%SystemRoot%\System32\newSS.scr"
'REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V ScreenSaveActive /T REG_SZ /F /D 1
For Each subkey In arrSubKeys
'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
oReg.SetStringvalue HKEY_USERS,Strkeypath,"SCRNSAVE.EXE", "%SystemRoot%\System32\newSS.scr"
Next
End Sub
Dim mmachineNames()
Const NumMachines =2
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(1) = "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)
Else
X=X+1
end if
next
wScript.stdOut.WriteLine "Script finished. Successfully processed " & X & " of " & ubound(mmachinenames)+1 & " Machines."
You'll still need to use the batch, to copy the screensaver. And then you can, instead of using REG ADD in your batch script, run "Cscript newscript.vbs"
remember, however, to modify the lines:
Const NumMachines =2
and
mmachinenames(0) = "." 'this reflects the local machine. This was for my testing, change it :P
mmachinenames(1) = "SATELLITE"
to reflect the names of the PCs your fiddling with on the network, as well as the number.
In my testing I was getting permission denied when it tried to change my laptop, "SATELLITE"'s, registry. I think it was simply the way I had things configured- not necessarily a network setup.
I hope the remote portions work for you. It reports the number that suceed after the script runs- (it doesn't quit of one fails, so if, say, one of the PCs is off, it won't simply stop there).
-
@BC, i didn't see OP's mentioned WMI is disabled (maybe i missed), if so, wouldn't the vbscript not work as it use WMI??
-
He mentioned disabling WMI on a group of machines in an earlier thread....
-
@BC, i didn't see OP's mentioned WMI is disabled (maybe i missed), if so, wouldn't the vbscript not work as it use WMI??
He mentioned disabling WMI on a group of machines in an earlier thread....
I remembered that myself, which is why I checked :)
well, VBScript might be out- because- get this-
it uses WMI, and I believe you recently disabled that?
oh the irony! :P
No that was on a different group of computers. :P
-
Thank you for the script BC_Programmer! I will give it a try.
EDIT: I have been searching, but i don't think it's possible. Could i use a wildcard in the registry.
I.E.
REG ADD "\\timscomputer\HKU\WILDCARD\Control Panel\Desktop" /V SCRNSAVE.EXE /T REG_SZ /F /D "%SystemRoot%\System32\newSS.scr"
I have tried a few but it just create a string with that name. :(
-
Maybe i was doing it incorrectly. I am trying to get entry to be in every user profile. So i would need the script to somehow look up or place the reg key for every profile. Then i need to be able to add the computer names.
I.E. \\REMOTEPC\HKU\SID\Control Panel\Desktop" /V SCRNSAVE.EXE /T REG_SZ /F /D "%SystemRoot%\System32\ITEP SS_UTI Version.scr"
REG ADD "\\REMOTEPC\HKU\SID\Control Panel\Desktop" /V ScreenSaveActive /T REG_SZ /F /D 1
I just do not know how to have the code translate every SID to a user name. I did get it to work, just only for the ".DEFAULT" profile. This will only help me with new setups. I need to make these changes to computer that could have 20+ profiles on them. Any ideas?
-
your supposed to change:
Const NumMachines =2
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(1) = "SATELLITE"
that portion. right now, the mmachinesNames Array is being set to some test names (well, "." for local machine, and SATELLITE for my laptop.\\ change the 'NumMachines=2" to Nummachines=<number of PCs>, and mmachineNames to the proper PC names.
Oh and I have a teensy mistake in my script:
instead of
oReg.SetStringvalue HKEY_USERS,Strkeypath,"SCRNSAVE.EXE", "%SystemRoot%\System32\newSS.scr"
this should be:
oReg.SetValue(HKEY_USERS, strkeypath, "SCRNSAVE.EXE", REG_EXPAND_SZ, "%SystemRoot%\System32\newSS.scr"
-
Okay, i have make some changes. Also i cannot add it to HKCU, it needs to be in HKU. Can you please look over my changes? Do i need the underlined parts?
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
'REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V SCRNSAVE.EXE /T REG_SZ /F /D "%SystemRoot%\System32\newSS.scr"
'REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V ScreenSaveActive /T REG_SZ /F /D 1
For Each subkey In arrSubKeys
'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
oReg.SetValue(HKEY_USERS, strkeypath, "SCRNSAVE.EXE", REG_EXPAND_SZ, "%SystemRoot%\System32\newSS.scr"
Next
End Sub
Dim mmachineNames()
Const NumMachines =2
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) = "testpc"
mmachinenames(1) = "imagepc"
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)
Else
X=X+1
end if
next
wScript.stdOut.WriteLine "Script finished. Successfully processed " & X & " of " & ubound(mmachinenames)+1 & " Machines."
-
you need the third underlined line. the first two are comments- they start with '.
I had them there, so I could remember what the keys where you wanted changed.
remember if you have more then 2 machines you can change the constant (Const NumMachines =2) to a higher number and add them where you now have "testpc" and "imagepc".
If net view reveals the names of the PCs you want to change somebody clever in the use of batch might be able to generate a base listing through manipulation of that output.
-
Now i am getting an error:
(http://img.photobucket.com/albums/v206/Michael_IStall/error.jpg)
-
what is the entire script as it is now?
-
It says the error is in line 27. Here is line 27.
oReg.SetValue(HKEY_USERS, strkeypath, "SCRNSAVE.EXE", REG_EXPAND_SZ, "%SystemRoot%\System32\ITEP SS_UTI Version.scr"
Thank you so much for your assistance by the way! Do i actually need to change the "strikeypath" or do i leave that there?
Code: ... i changed file names and the test computer.
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
'REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V SCRNSAVE.EXE /T REG_SZ /F /D "%SystemRoot%\System32\ITEP SS_UTI Version.scr"
'REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V ScreenSaveActive /T REG_SZ /F /D 1
For Each subkey In arrSubKeys
'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
oReg.SetValue(HKEY_USERS, strkeypath, "SCRNSAVE.EXE", REG_EXPAND_SZ, "%SystemRoot%\System32\ITEP SS_UTI Version.scr"
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) = "u1jbennett"
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)
Else
X=X+1
end if
next
wScript.stdOut.WriteLine "Script finished. Successfully processed " & X & " of " & ubound(mmachinenames)+1 & " Machines."
-
ok, found the problem. also fixed something else.
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
'REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V SCRNSAVE.EXE /T REG_SZ /F /D "%SystemRoot%\System32\ITEP SS_UTI Version.scr"
'REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V ScreenSaveActive /T REG_SZ /F /D 1
For Each subkey In arrSubKeys
'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(HKEY_USERS, strkeypath, "SCRNSAVE.EXE", REG_EXPAND_SZ, """%SystemRoot%\System32\ITEP SS_UTI Version.scr""")
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) = "u1jbennett"
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)
Else
X=X+1
end if
next
wScript.stdOut.WriteLine "Script finished. Successfully processed " & X & " of " & ubound(mmachinenames)+1 & " Machines."
this is the new line:
oReg.SetValue(HKEY_USERS, strkeypath, "SCRNSAVE.EXE", REG_EXPAND_SZ, """%SystemRoot%\System32\ITEP SS_UTI Version.scr""")
it didn't have a ) at the end. Also, since it has spaces, it will need to be quoted when placed in the registry. two quotes in a VBScript string equal one, which is why it has three on each end. Also, is the path correct? is the Screensaver in System32, or in a folder called "ITEP" in system32? (just checking ;))
-
The name of the file is "ITEP SS_UTI Version.scr" ... not my decision or there would be no spaces...
I am getting another error on the same line now. I didn't change anything this time. ;)
error:
(http://img.photobucket.com/albums/v206/Michael_IStall/Screenshot_0064_06_10_2009.jpg)
-
woops, my bad. Guess I' just too used to the VB6 IDE fixing these types of mistakes for me! :P
change:
oReg.SetValue(HKEY_USERS, strkeypath, "SCRNSAVE.EXE", REG_EXPAND_SZ, """%SystemRoot%\System32\ITEP SS_UTI Version.scr""")
to
oReg.SetValue HKEY_USERS, strkeypath, "SCRNSAVE.EXE", REG_EXPAND_SZ, """%SystemRoot%\System32\ITEP SS_UTI Version.scr"""
-
Okay, now there are no errors. Now the issue is that i went to the machine that it should have changed and it did not change it. Any ideas? It should change the screen saver for every user even if the profile exists.
Thank you again for the help!
EDIT: when you double click the VBS it does not flash anything, it just has the "busy" mouse for a second.
-
well- you should instead run it via the command line, using cscript.
this way it will report any issues changing the registry keys and/or connecting to the remote PC.
Also make sure that the remote PC has that set of keys permissions set to "full control" for "everybody".
-
Ok, i ran it from a BAT file and here is the results ...
1 file(s) copied.
Press any key to continue . . .
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.
Connecting to u1jbennett
Error processing machine, u1jbennett
Script finished. Successfully processed of 1 Machines.
Press any key to continue . . .
Why would it say this Error processing machine, u1jbennett
??
EDIT: I checked the registry on the remote machine and the registry for those setting were not changed.
-
probably, a permission denied error.
by default, XP only let's remote PC's Look at it's registry keys, not change them.
But, the problem here, is that you would need to somehow change the permissions on all the machines, which would kind of make the script a moot point, unless you can find a way to automate that, as well. :(
-
I am part of a domain admin group in AD. That group is the "administrators" group on the local machines. Wouldn't that give me the proper rights to the machine? Do you think there would be any difference if it was run from the DC?
I shouldn't need to use any of the switches i don't think...
Usage: CScript scriptname.extension [option...] [arguments...]
Options:
//B Batch mode: Suppresses script errors and prompts from displaying
//D Enable Active Debugging
//E:engine Use engine for executing script
//H:CScript Changes the default script host to CScript.exe
//H:WScript Changes the default script host to WScript.exe (default)
//I Interactive mode (default, opposite of //B)
//Job:xxxx Execute a WSF job
//Logo Display logo (default)
//Nologo Prevent logo display: No banner will be shown at execution time
//S Save current command line options for this user
//T:nn Time out in seconds: Maximum time a script is permitted to run
//X Execute script in debugger
//U Use Unicode for redirected I/O from the console
This is the line that i have to call the script:
cscript "%~dp0\Itep_SS.vbs"
I noticed in the script there is a part that looks undefined...could that have something to do with it? strKeyPath = ""
-
I am part of a domain admin group in AD. That group is the "administrators" group on the local machines. Wouldn't that give me the proper rights to the machine? Do you think there would be any difference if it was run from the DC?
well, both the accounts on my laptop and my desktop were logged in as administrator, and it still gave me permission denied. we can find out exactly what the error number is though, to confirm.
change the line:
wScript.stdOut.WriteLine "Error processing machine, " & mmachinenames(I)
to
wScript.stdOut.WriteLine "Error processing machine, " & mmachinenames(I) & " error: " & err
I noticed in the script there is a part that looks undefined...could that have something to do with it? strKeyPath = ""
Nope... that was on purpose.
-
Alright, I just changed it and ran the BAT that calls it.
Here is the results:
1 file(s) copied.
Press any key to continue . . .
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.
Connecting to u1jbennett
Error processing machine, u1jbennett error: 438
Script finished. Successfully processed of 1 Machines.
Press any key to continue . . .
I looked it up and this was the description:
Object doesn't support this property or method
-
ahh, 438.
odd.
Object doesn't support this property or method
Strange.
I tried the same script, changed the names of the PCs, and I got error 70 again, Permission denied.
There might be, a mistake copying it, though, the name of a method or somesuch.
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
'REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V SCRNSAVE.EXE /T REG_SZ /F /D "%SystemRoot%\System32\ITEP SS_UTI Version.scr"
'REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V ScreenSaveActive /T REG_SZ /F /D 1
For Each subkey In arrSubKeys
'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"""
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."
Also, make sure the WMI service "Windows Management Instrumentation" is running on both PCs.
I'll say this, this seemingly simply problem is becoming a real doozy!
-
Weird ... i copied the script you posted in your last post and this is what returned.
1 file(s) copied.
Press any key to continue . . .
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.
Connecting to Satellite
Error processing machine, SatelliteError:70
Press any key to continue . . .
And i made sure WMI was enabled.
You are totally correct... this is becoming a major pain! Thank you for helping me! ;D
-
hmm... you got permission denied.
But this time- you tried to connect to a fictitious "Satellite" on your network :P
Sorry I had to change the PC name back to SATELLITE to test it over here. Try changing it back and see if you get the previous, 438 error again.
-
I am sorry i didn't notice you changed that. I am running on 4 hours of sleep today and it is catching up with me. :-[ I changed it back and received the same error:
Connecting to u1jbennett
Error processing machine, u1jbennettError:438
Press any key to continue . . .
-
well, I'll be honest...
I haven't got a clue what the heck is going on. the error made me think it was simply a typing mistake or something similar, but that isn't the case.
I did a few quick googles and the onlything I can think of, is if the other PC is running an OS before windows XP, the error might occur.
-
Bummer! Both are running XP Pro.
Well thank you soo much for your time! I really do appreciate it. ;D
-
Well, last ditch idea, is I could try to write a little VB6 program. Maybe my Registry class can cut through this WMI crap. It's written right to the API, none of this obtuse error crap. ;D
-
...
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!
-
Hmmm.... now i get the following:
1 file(s) copied.
Press any key to continue . . .
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.
Connecting to u1jbennett
Failed to change key .DEFAULT\Control Panel\Desktop on machine u1jbennett
error was
Failed to change key S-1-5-19\Control Panel\Desktop on machine u1jbennett
error was
Failed to change key S-1-5-19_Classes\Control Panel\Desktop on machine u1jbennet
t
error was
Failed to change key S-1-5-20\Control Panel\Desktop on machine u1jbennett
error was
Failed to change key S-1-5-20_Classes\Control Panel\Desktop on machine u1jbennet
t
error was
Failed to change key S-1-5-21-1130582348-1049843267-782984527-50788\Control Pane
l\Desktop on machine u1jbennett
error was
Failed to change key S-1-5-21-1130582348-1049843267-782984527-50788_Classes\Cont
rol Panel\Desktop on machine u1jbennett
error was
Failed to change key S-1-5-18\Control Panel\Desktop on machine u1jbennett
error was
Error processing machine, u1jbennettError:438
Press any key to continue . . .
-
hmmm, thats 6 keys that failed- probably all of them.
Wow, you'd probably have better luck doing this manually!
-
/cry ... I'll maybe work on a BAT file running the the startup folder. The students are locked down from this area and shouldn't be able to make changes. Thank you so much for trying to get this to work for me. I really, really appreciate your time!
Have a good one!
-
If it's any consolation, at least I perfected my registry Access routines for use with network PCs.
-
As long as we both learned something from the experience, then i say i was worth it!