Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to change This particular registry value

Status
Not open for further replies.

edoe

IS-IT--Management
Mar 22, 2011
1
SE
Hello, our GP set the screensavetimeout to 600s and this is locked down. It irritates the hell out of the teachers that using smartboards as they have to log in again in the middle of explaining something.

What I want is a script that they can run that will extend the timeout- say 30 mins /1800s

I DL'd a script that changed ScreenSaveTimeOut in another part of the registry but that is not the one that affects the timeout for out screensavers.

This is the key that sets the timeout.

HKEY_USERS\S-1-5-21-187661315-68905663-1388069909-20081\Software\Policies\Microsoft\Windows\Control Panel\Desktop\ScreenSaveTimeOut

I can change this manually.

and this is the code that will not work with that key, but does work on another key,

Set oShell = CreateObject("WScript.Shell")
oShell.RegWrite "HKEY_USERS\S-1-5-21-187661315-68905663-1388069909-20081\Software\Policies\Microsoft\Windows\Control Panel\Desktop", "ScreenSaveTimeOut", "1800"
oShell.run "c:\windows\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True

Where am I going wrong here? is it a syntax error or not possible? but i can change it manually. I'm goung round and round in circles with this one. Any help would be greatly appreciated.
Thanks
 
Try this - or any part of it.

Code:
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop]
"ScreenSaveActive"="1"
"ScreenSaverIsSecure"="1"
"ScreenSaveTimeOut"="1800"

Kind regards
Mirko
--------------------------------------
>>>>>> ... I am sure, some supportissues are a matter of PEBKAC ... <<<<<
 
Code:
Set oShell = CreateObject("WScript.Shell")oShell.RegWrite "HKEY_USERS\[red]S-1-5-21-187661315-68905663-1388069909-20081[/red]\Software\Policies\Microsoft\Windows\Control Panel\Desktop", "ScreenSaveTimeOut", "1800"
oShell.run "c:\windows\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True

The key points to a specific user hive, S-1-5-21-187661315-68905663-1355069909-20081. Each username has a unique idenifier, a SID. If the teachers are logging on with unique usernames, they are using different SIDs. The script must first correctly determine the SID of the user logged on. Once obtained, the reg hack can be applied to the correct user hive (SID).

Enumerate the ProfileList reg key and compared each value with the username argument. These functions were written with remote usage in mind. If the script is local, pass a period (.) as the strComputer argument.

Code:
function getUserSID (strComputer, strUserName)
   set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
   getUserSID = "Unknown"
	
   objReg.EnumKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList", arrSIDs
	
   for i = 0 to ubound(arrSIDs)
      strSID = arrSIDs(i)
      objReg.GetExpandedStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" & strSID, "ProfileImagePath", strValue
      if (inStr(ucase(strValue), ucase(strUserName))) then
         getUserSID = strSID
         exit function
      end if
   next
end function

Get the current user (XP and 2000)
Code:
function getCurrentUser(strComputer)
   getLastUser = "Unknown"
   set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
   objReg.GetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName", strUserName
   if (len(strUserName) <> 0) then getLastUser = strUserName
end function

with the above functions, your main script should look like...
Code:
set oShell = CreateObject("WScript.Shell")

strCurrentUser = getCurrentUser(".")
strSID = getUserSID (".", strCurrentUser)
oShell.RegWrite "HKEY_USERS\" & strSID & "\Policies\Microsoft\Windows\Control Panel\Desktop", "ScreenSaveTimeOut", "1800"

'reload user registry hive
oShell.run "c:\windows\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True

Although, I'm not sure the user hive is the issue

-Geates

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
- Martin Golding

"There are seldom good technological solutions to behavioral problems."
- Ed Crowley, Exchange guru and technology curmudgeon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top