Page 1 of 2 12>
Topic Options
#116235 - 2004-03-17 12:02 AM screensaver/registry issue - little help?
MDavis Offline
Fresh Scripter

Registered: 2004-01-05
Posts: 40
Loc: New Orleans, LA
Okay, this is the same script I have been working on for 3 days now, WOOHOO! It is certainly coming along, but I am having some issues wit hthe screensaver. All of the changes are being done remotely from a PC having a logged in user with domain admin priv. The workstation I am testing on is a w2k with service pack 4. I have browsed throughout the site looking for similar issues and I am trying the solutions, but I don't get the results I want. The problem I am having is that even though I set the screensaver in both keys mentioned throughout the site the screen saver when browsed through display properties say there is "none" specified. I check the keys, I restart the system, but still no dice. I even tried writing to system.ini based on another thread...nothing. If I could get some fresh eyes to look at my script and see where it is I am going wrong, that would be awesome. I am also using the latest version of Kix. I think that is everything can include, if I have left something out, just ask. Thanks.

Code:

Dim $RID, $regKUpwr, $regDefpwr, $regKUdesk, $regKUcpl, $regLMcpl, $regLMCV, $r, $comp, $sysini
Dim $SID, $domain, $user, $HKU, $HKLM, $u, $SystemRoot, $DEFAULT, $IE, $IEshare, $cshare


Call getsid.kix
Call loggedinusers.kix
Call StopProc.kix

$domain = "SALCO1"
$comp = "TESTBOX"
$tcomp = "\\" + $comp
$HKU = "\HKEY_USERS\"
$HKLM = "\HKEY_LOCAL_MACHINE"
$DEFAULT = $HKU + ".DEFAULT"

$u = loggedinusers($comp)

If Ubound($u) = -1
? "Noone Logged in"
Else
$user = $u[0]
$user = Split($user,"\")[1]
$IE = "C:\Documents And Settings\" + $user + "\Application Data\Microsoft\Internet Explorer"
$IEshare = "\C$\Documents And Settings\" + $user + "\Application Data\Microsoft\Internet Explorer"
$SID = getsid("WinNT://" + $domain+ "/" + $user + ",USER")
$regKUpwr = $HKU + $SID + "\Control Panel\PowerCfg"
$regDefpwr = $DEFAULT + "\Control Panel\PowerCfg"
$regKUdesk = $HKU + $SID + "\Control Panel\Desktop"
$regKUcpl = $HKU + $SID + "\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
$regLMcpl = $HKLM + "\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
$regKUCV = $HKLM + "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
$regKUPoldesk = $HKU + $SID + "\Software\Policies\Microsoft\Windows\Control Panel\Desktop"
$SystemRoot = ReadValue($tcomp + $regKUCV,"SystemRoot")

Select
Case $SystemRoot = "c:\WINNT"
$cshare = "\c$\winnt"
Case $SystemRoot = "c:\windows"
$cshare = "\c$\windows"
Case 1
? "boo"
EndSelect
$sysini = $cshare + "\System.ini"

$RID = Split($SID,"-")[7]
If $RID = 500
? $RID
Else
EndIf

$r = WriteValue($tcomp + $regKUpwr,"CurrentPowerPolicy","3","REG_SZ")
$r = WriteValue($tcomp + $regDefpwr,"CurrentPowerPolicy","3","REG_SZ")

;$r = WriteValue($tcomp + $regKUcpl,"NoControlPanel","1","REG_DWORD")
;$r = WriteValue($tcomp + $regLMcpl,"NoControlPanel","1","REG_DWORD")

$r = WriteValue($tcomp + $regKUdesk,"ScreenSaverIsSecure","1","REG_SZ")
$r = WriteValue($tcomp + $regKUdesk,"ScreenSaveActive","1","REG_DWORD")
$r = WriteValue($tcomp + $regKUdesk,"SCRNSAVE.EXE", $SystemRoot + "\system32\logon.scr","REG_SZ")
$r = WriteValue($tcomp + $regKUPoldesk,"ScreenSaverIsSecure","1","REG_SZ")
$r = WriteValue($tcomp + $regKUPoldesk,"ScreenSaveActive","1","REG_DWORD")
$r = WriteValue($tcomp + $regKUPoldesk,"SCRNSAVE.EXE", $SystemRoot + "\system32\logon.scr","REG_SZ")

Copy salco.bmp $tcomp + "\c$"
If Exist($tcomp + $IEshare + "\Internet Explorer Wallpaper.bmp")
Del $tcomp + $IEshare +"\Internet Explorer Wallpaper.bmp"
Else
EndIf

If Exist($tcomp + $IEshare + "\Internet Explorer Wallpaper.bmp")
Del $tcomp + $IEshare + "\Internet Explorer Wallpaper.bmp"
Else
EndIf

If Exist($tcomp + $cshare + "\Webshots for " + $user + ".bmp")
Del $tcomp + $cshare + "\Webshots for " + $user + ".bmp"
Else
EndIf

If Exist($tcomp + $cshare + "\webshots.scr")
StopProc("Webshots.scr",$comp)
Del $tcomp + $cshare + "\webshots.scr" /f
Else
EndIf

MD $tcomp + $cshare + "\Webshots for " + $user + ".bmp"
MD $tcomp + $cshare + "\webshots.scr"
MD $tcomp + $IEshare + "\Internet Explorer Wallpaper.bmp\"

If $SystemRoot + "\System32\logon.scr" <> ReadProfileString($tcomp + $sysini,"boot","scrnsave.exe")
$r = WriteProfileString($tcomp + $sysini,"boot","scrnsave.exe",$SystemRoot + "\System32\logon.scr")
? @SERROR
Else
EndIf

$r = WriteValue($tcomp + $regKUdesk,"Wallpaper","C:\salco.bmp","REG_SZ")
$r = WriteValue($tcomp + $regKUdesk,"WallpaperStyle","0","REG_SZ")
EndIf

_________________________
Micah Davis "A truly wise man never plays leapfrog with a unicorn."

Top
#116236 - 2004-03-17 04:28 AM Re: screensaver/registry issue - little help?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
A lot of the screensaver issues can be tracked to the fact that the user environment needs to be refreshe din order for the changes to take. See UpdateUserParameters() in the UDF Forum. You iwll need to execute this under the remote user's context on the remote computer. This might solve your problem. YMMV.
_________________________
There are two types of vessels, submarines and targets.

Top
#116237 - 2004-03-17 07:08 AM Re: screensaver/registry issue - little help?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Hmmm... perhaps a little bit different coding style, but no obvious syntax errors. Try adding debug statements in your code to see if you're having errors.

On the remote machine, is the registry value being udpated correctly?

Why aren't you doing this via a GPO or NT Policy from the Server?

I find it difficult to understand why Companies or Admins at Companies find the need to force a specific screen saver or wallpaper on a user. If it has nothing to do with security who cares what wallpaper or screen saver a user runs.

Anyways.... try some debug statements and it should help you to track down the issue.

Also.. try adding this to all of your code at the top of the scripts

DIM $RC
$RC=SetOption('Explicit','On')
$RC=SetOption('NoVarsInStrings','On')

Also as part of your debug statements, make sure your calls to external files are actually loading and working correctly.

Top
#116238 - 2004-03-17 06:00 PM Re: screensaver/registry issue - little help?
MDavis Offline
Fresh Scripter

Registered: 2004-01-05
Posts: 40
Loc: New Orleans, LA
Jens,
Would rebooting or logging off and logging back on duplicate the effect of the UpdateUserParameters() UDF? I've rebooted the system in an attempt to apply the settings in hope that was the issue but to no avail.

NTDOC,

I'll try the debug statements. I had a ?@serror after every function and everything was coming back successfull, but maybe I've missed somethng. The registry value is certainly being update correctly, that is where the confusion comes in. Everything looks perfect in the registry as per the instructions I have found, it is just the the screensaver is saying 'none'. The reason we aren't doing this via the server is for a couple reasons; We are considering doing an update to 2003 and my boss wanted to wait until 2003 was here so we could start from the ground up and do things right. We also needed a quick fix for it (it seems like the quick fix is turning into a drawn out fix). I am the only one here doing any of these types of changes too, and I am having to learn as I go. Not everything is set up the way it should have been from the start and have little support to make changes to server aspects, so I have to do it from the user end. I do however need to learn about making custom policies, it's something I not ALL the familiar with right now. As far as the screensavers and wallpapers are concerned, we use VNC to remote to the machines and VNC doesn't always remove the wallapapers that are on the remote machines like it should, and it is a real pain to try to navigate a machine via VNC with it trying to contantly refresh the wallpaper. The screensavers are just for conformity and for webshots.

Thanks so much for the recommendations, I'm going to try those and I'll get back with you.
_________________________
Micah Davis "A truly wise man never plays leapfrog with a unicorn."

Top
#116239 - 2004-03-17 06:01 PM Re: screensaver/registry issue - little help?
MDavis Offline
Fresh Scripter

Registered: 2004-01-05
Posts: 40
Loc: New Orleans, LA
Heh, look no longer a "stranger". Cool!
_________________________
Micah Davis "A truly wise man never plays leapfrog with a unicorn."

Top
#116240 - 2004-03-17 06:27 PM Re: screensaver/registry issue - little help?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Quote:

Would rebooting or logging off and logging back on duplicate the effect of the UpdateUserParameters



I don't thinkso, you'll have to give it a try. I'd rather use GPOs for this, anyway.
_________________________
There are two types of vessels, submarines and targets.

Top
#116241 - 2004-03-17 06:45 PM Re: screensaver/registry issue - little help?
MDavis Offline
Fresh Scripter

Registered: 2004-01-05
Posts: 40
Loc: New Orleans, LA
Still didn't work. Tried logging off and logging back out, rebooting, and useing the UpdateUserParameters() UDF as well. I wish I could use GPO, but we are on an NT network. This may be a little off topic, but what would be the most efficient way to accomplish this task in an NT environment, since the Kix way seems to be more of a pain.
_________________________
Micah Davis "A truly wise man never plays leapfrog with a unicorn."

Top
#116242 - 2004-03-17 06:50 PM Re: screensaver/registry issue - little help?
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Hi

Have a look at the following code, the important part is "setm 'ss='"


Code:
 ;Check/Modify ScreenSaver Settings
if @producttype="Windows 2000 Professional"
$ss_key="HKEY_CURRENT_USER\Control Panel\Desktop"
$ss_name=readvalue($ss_key,"SCRNSAVE.EXE")
$ss_secure=readvalue($ss_key,"ScreenSaverIsSecure")
$ss_timeout=readvalue($ss_key,"ScreenSaveTimeOut")
if $ss_name=""
$=WRITEVALUE($ss_key,"SCRNSAVE.EXE","C:\WINNT\SYSTEM32\LOGON.SCR","REG_SZ")
endif
if $ss_secure=0
$=WRITEVALUE($ss_key,"ScreenSaverIsSecure","1","REG_SZ")
endif
if (val($ss_timeout) <= 300 ) OR (val($ss_timeout) > 1800)
$=WRITEVALUE($ss_key,"ScreenSaveTimeOut","900","REG_SZ")
endif
setm 'ss='
endif


Top
#116243 - 2004-03-17 10:16 PM Re: screensaver/registry issue - little help?
MDavis Offline
Fresh Scripter

Registered: 2004-01-05
Posts: 40
Loc: New Orleans, LA
Quote:

Have a look at the following code, the important part is "setm 'ss='"



Okay, maybe I am a little slow! But, I am not sure how to edit the script so that I get rid of the following message on the line with "setm 'ss='"

Quote:

The system cannot find the file specified.




It may sound like a silly question, but and I supposed to put:

Code:
setm 'ss=c:\winnt\system32\logon.scr'

??

Thanks for all your help! I have been actually messing with policies to see if I can figure out a better way for this. But screensavers are not specified in policy editor that I can tell (for NT at least)
_________________________
Micah Davis "A truly wise man never plays leapfrog with a unicorn."

Top
#116244 - 2004-03-17 10:31 PM Re: screensaver/registry issue - little help?
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
You don't have to change that line at all. SETM SS= is just setting a arbitrary variable(SS) to nothing. But when you do this, it makes explorer check the settings in the registry for updates. This doesn't work for everything, but it usually works for Screensaver settings.

See this post for more details: Applying Registry Settings

I would be willing to bet, Jen's UDF does very much the same thing, so if that UDF is not working, this may not work either.

Top
#116245 - 2004-03-17 10:45 PM Re: screensaver/registry issue - little help?
MDavis Offline
Fresh Scripter

Registered: 2004-01-05
Posts: 40
Loc: New Orleans, LA
Al_Po,

Ahhh, I was wondering what that was for! Well the problem is that when I use that exact line, I get the "system can't find the file specified" error from @SERROR. I did however find out something interesting. After I wrote the reg key to HKCU\Control Panel\Desktop I restarted the computer and logged back in, then checked the registry for all instances of the key that I wrote, i.e. "logon.scr". I found one, in HKCU\Control Panel\Desktop. I then did a manual change to the screensaver to change it to mystify. I checked HKCU\Control Panel\Desktop and noticed that it had changed to C:\WINNT\system32\ssmyst.scr from C:\WINNT\system32\logon.scr. I did another search, this time for ssmyst.scr and found TWO instances of the value. One is HKCU and one in HKU\SID. So apparently when I am writting to HKCU while logged in, it is not updating the HKU\SID registry location. This is also a fresh installation with all the windows updates/service packs etc. WTF? Think I should just write to both locations? And what about doing it remotely?
_________________________
Micah Davis "A truly wise man never plays leapfrog with a unicorn."

Top
#116246 - 2004-03-17 10:49 PM Re: screensaver/registry issue - little help?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
HKCU and HKU\SID where SID is the currently logged on user is one and the same registry location. It is just smoke and mirrors. If you are not seeing the same results, then you are not translating the SID correctly.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#116247 - 2004-03-17 10:55 PM Re: screensaver/registry issue - little help?
MDavis Offline
Fresh Scripter

Registered: 2004-01-05
Posts: 40
Loc: New Orleans, LA
Les,

Yeah, I got all that. The issue is that when I write to HKCU it does not update the HKU\SID respective area, even after a reboot. I could totally understand if I was initially writing to HKU\SID and HKCU was not being updated. The thing is, everything is being written to the registry correctly, I can physically check all the changes I am making. I just feel like I am missing something.
_________________________
Micah Davis "A truly wise man never plays leapfrog with a unicorn."

Top
#116248 - 2004-03-17 10:57 PM Re: screensaver/registry issue - little help?
MDavis Offline
Fresh Scripter

Registered: 2004-01-05
Posts: 40
Loc: New Orleans, LA
I got an idea, if someone has a test machine they can use, can you test the script? I think the only changes you need to make would be the $domain and $comp. Thanks
_________________________
Micah Davis "A truly wise man never plays leapfrog with a unicorn."

Top
#116249 - 2004-03-17 11:07 PM Re: screensaver/registry issue - little help?
MDavis Offline
Fresh Scripter

Registered: 2004-01-05
Posts: 40
Loc: New Orleans, LA
I got it to work. I was browsing the web and ran across an article on Restrict the Screen Saver
and it said to references a COMPLETELY different key. I can only assume that was the issue.

HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop was they key they claimed was the correct key.

I am not sure, but my head hurts from thinking about this too much. Thanks for everyone's help.
_________________________
Micah Davis "A truly wise man never plays leapfrog with a unicorn."

Top
#116250 - 2004-03-17 11:16 PM Re: screensaver/registry issue - little help?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Whis is a registry key used to enforce policies regarding the screensaver. Teh read screensaver registry key is in HKCU\Desktop.

You might also want to doublecheck yoru syntax and use DEBUG ON to determine why it fails on the SET.
_________________________
There are two types of vessels, submarines and targets.

Top
#116251 - 2004-03-17 11:24 PM Re: screensaver/registry issue - little help?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

Yeah, I got all that



I would have to say you are missing my point. HKCU and HKU\SID are one and the same registry location... just looking from a different viewpoint. ANything you change in HKCU is reflected in HKU\SID and visa versa.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#116252 - 2004-03-17 11:38 PM Re: screensaver/registry issue - little help?
MDavis Offline
Fresh Scripter

Registered: 2004-01-05
Posts: 40
Loc: New Orleans, LA
Jens,
I am sure that is the case, but all I know is that no matter how many times I changed HKCU\Cpl\Desktop it did not change the screensaver, but ONLY the specific screensaver I was defining, all other settings worked, i.e. screensaversecure, screensaveractive. When I wrote to
HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop it set the screensaver no problems.

I ran through the script with debug on and I figured out that it is saying that the system cannot find the file specified. Maybe there is extensive funtionability to debug on that I am not aware of, but all I could see was the ability to see what happens line by line. It tries to apply the setting and then it hits the ? @SERROR i have positioned after it and it spits out that the system cannot find the file specified.

Les,

No, really I totally understand that. And I am not disagreeing with that fact, I am just telling you what is happening, not what is SUPPOSED to happen. When I am writing to HKCU it is NOT adding the key to HKU\SID, don't ask my why not...it just isn't. I've checked a couple times now.

I am certainly not trying to tell either of you "how it is supposed to be" I am just explaining what my own eyes have seen. Maybe I should move the test pc to Eerie Indiana?
_________________________
Micah Davis "A truly wise man never plays leapfrog with a unicorn."

Top
#116253 - 2004-03-17 11:46 PM Re: screensaver/registry issue - little help?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
If you write to HKCU\Desktop\... to update the sreensaver, it will ALSO be written to HKU\sid_of_user because they are ONE AND THE SAME! If you do not refresh the environment after the registry write, the currently set screensaver will be written back to HKCU and OVERWRITE your changes.

The POLICIES registry key is a DIFFERENT methodology to enforce a screensaver, namely via GPO/LPO. One can write to the various POLICIES subkeys in order to OVERRIDE the corresponding regular registry keys.

Why don't you use the 'set screensaver' UDF that is in the UDF Forum?
_________________________
There are two types of vessels, submarines and targets.

Top
#116254 - 2004-03-18 12:07 AM Re: screensaver/registry issue - little help?
MDavis Offline
Fresh Scripter

Registered: 2004-01-05
Posts: 40
Loc: New Orleans, LA
Okay, Okay! I believe you! Like I said, I never argued that point. Anyway, I would use the setscreensaver UDF but it has to be run localy, and I am trying to do this remotely. Is there a way to refresh the environment remotely?
_________________________
Micah Davis "A truly wise man never plays leapfrog with a unicorn."

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.074 seconds in which 0.028 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org