Page 1 of 2 12>
Topic Options
#105301 - 2003-10-02 12:10 AM ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Sparko Offline
Fresh Scripter

Registered: 2003-10-01
Posts: 6
[Moderator (Sealeopard): Moved thread from 'Scripts' to 'General' forum due to lack of script in body]

I am making a logon script that will force the password-protected screen saver on and remove the Screen Saver tab from desktop properties in Windows 2000. The password-protected screen saver IS being forced on on all systems, but the tab removal is not.

I am finding that in some cases the key

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System

does not exist. Attempts to add it with

ADDKEY
("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System")

do not work. I have also tried

WRITEVALUE("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System","NoDispScrSavPage","1","REG_DWORD")

but that doesn't work either. Can anyone tell me what I'm doing wrong here, please?

[ 01. October 2003, 23:46: Message edited by: sealeopard ]

Top
#105302 - 2003-10-01 01:18 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
You will need to add a value before writing to it. You can create the value by merging a reg file into your registry. Then do a write value to the added value.

The reg file would look something like this in your case.

code:
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"NoDispScrSavPage"=""

Create it in notepad or some other text editor and save it as filenam.reg.

After the merge you can write to the value using writevalue.

Tested it and works fine for me.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#105303 - 2003-10-01 01:51 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Sparko Offline
Fresh Scripter

Registered: 2003-10-01
Posts: 6
Thanks. Ummmm, how would I execute this merge?

Also, I've found that my script works fine for users with admin privileges, but not regular users. Is there a way around this?

Top
#105304 - 2003-10-01 01:53 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
quote:

You can create the value by merging a reg file into your registry.

This is true with multiple entries into the registry. However, with only a couple KEYS/VALUES, this is not necessary.

The best practice in this example is to use a GPO. There is a GPO to hide the Screensaver tab as well as a timeout value and screensaver type.

Kent

[ 01. October 2003, 13:54: Message edited by: kdyer ]
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#105305 - 2003-10-01 02:01 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Yep, but what if you're not using W2k or up [Confused] some sort of merge would be necessary then.

Merging the .reg file can be done like this:

code:
Shell "regedit /s " + @LDRIVE + "yourfilename.reg"

Normal users don’t have the privileges to edit reg keys. So they can’t f%$@#$ck it up it either.

You could run it as an admin with su.exe, remote execution manager, scheduled task or something like it. There's a topic in the FAQ's about this which explains it all.

http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=10;t=000017
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#105306 - 2003-10-01 02:06 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Why is a merge necessary? From the initial question posed, he clearly states Windows 2000.

If he has a policy in place, this will be a cinch.

If there are no policies in place, it will be pretty easy to add one.

If there is no policy and/or no domain, then add some @ERROR and/or @SERROR checking to see where the script bombs. Really, if that is the case, then maybe posting the real code rather than the pseudocode would be quite helpful.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#105307 - 2003-10-01 03:00 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Sparko Offline
Fresh Scripter

Registered: 2003-10-01
Posts: 6
Very well, here' my entire script, based on one I downloaded from this forum.

$hkcu = 'HKEY_CURRENT_USER'
$hkcus = 'HKEY_CURRENT_USER\SOFTWARE'
$screensavekey = $hkcu+"\Control Panel\Desktop"
$sysini = "%Windir%\System.ini"
$poleditkey = $hkcus+"\Microsoft\Windows\CurrentVersion\Policies\System"

if KeyExist( $poleditkey ) <> 0
$screensavetab = Readvalue($poleditkey,"NoDispScrSavPage")
if $screensavetab <> 1
WRITEVALUE($poleditkey,"NoDispScrSavPage","1","REG_DWORD")
endif
else
AddKey($poleditkey)
WRITEVALUE($poleditkey,"NoDispScrSavPage","1","REG_DWORD")
endif

; We have a key, and the tab is hidden. Now change other settings...
IF 600 <> Readvalue($screensavekey,"ScreenSaveTimeOut")
WRITEVALUE($screensavekey,"ScreenSaveTimeOut","600","REG_SZ")
ENDIF

; Turn screen saver on if it isn't already for non BDC London group members
IF 1 <> Readvalue($screensavekey,"ScreenSaveActive")
WRITEVALUE("HKEY_CURRENT_USER\Control Panel\Desktop","SCRNSAVE.EXE","logon.scr","REG_SZ")
WRITEVALUE($screensavekey,"ScreenSaveActive","1","REG_SZ")
ENDIF

; Password protect the screen saver
IF 1 <> Readvalue($screensavekey,"ScreenSaverIsSecure")
WRITEVALUE("HKEY_CURRENT_USER\Control Panel\Desktop","SCRNSAVE.EXE","logon.scr","REG_SZ")
WRITEVALUE($screensavekey,"ScreenSaverIsSecure","1","REG_SZ")
ENDIF

Top
#105308 - 2003-10-01 04:22 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Again, this really needs to be a GPO. Registry hacking should be a last resort.

From a DC, Start/Run/GPEDIT.MSC..
Local Computer Policy/Computer Configuration/User Configuration/Control Panel/Display
Hide Screen Saver tab

Enable it and you are done..

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#105309 - 2003-10-01 04:35 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
lol, last resort.
I'm on NT domain, so am I at last resort? [Razz]

R2D2, kix-user never needs to even think about merging.
we even have scripts here that do the merging on the behalf of regedit (works fine on systems where reg editing tools are disabled [Big Grin] )
_________________________
!

download KiXnet

Top
#105310 - 2003-10-01 04:46 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
He said W2k.. So, is this a W2k domain or an NT Domain?

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#105311 - 2003-10-01 04:49 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
quote:

desktop properties in Windows 2000

quote:

Why is a merge necessary? From the initial question posed, he clearly states Windows 2000.

No offense but windows 2000 server is NOT mentioned in the initial post or in later posts. So Sparko could be on NT servers and 2000 workstations, don’t know.

Sparko:
Are you on a 2k or NT domain. If your on 2k server GPO would indeed be the best option.

Lonkero:
I'm on NT servers and 2k workstations. The method I suggested works great for me. Never bothered to check for other ways. Maybe I should but an upgrade to 2k is planned before the end of 2003.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#105312 - 2003-10-01 04:52 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
If memory serves.. There is a policy (Poledit) to hide the screensaver tab on a NT Domain too.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#105313 - 2003-10-01 05:34 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Sparko Offline
Fresh Scripter

Registered: 2003-10-01
Posts: 6
The answer you've all been waiting for.... I'm on an NT domain with W2K workstations. As far as GPO's concerned I can access other systems from my workstation, but I'm really looking for an automated solution so that I don't have to reach out and touch every individual user's PC - hence the Kixtart logon script.

Whether the use of a script in this case is a good idea or not, we still have the challenge of discovering why I can't seem to change that one registry settiing.

Cheers.

Top
#105314 - 2003-10-01 05:53 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
r2d2 , your comment about MUST have merge is false.
you don't need any merging when you have kixtart.
if you want to keep on merging, fine.
but others are fine with kixtart writevalue() and addkey()

sparko, you should indeed invest in poledit.
with w2k and XP you can't write to the keys you want without admin rights.
_________________________
!

download KiXnet

Top
#105315 - 2003-10-01 06:34 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
POLEDIT should be installed on the NT DC and you can push this to your clients via Domain Admin login.

You need to be creating a %logonserver%\netlogon\NTconfig.pol which will be replicated to the other DCs on your domain. When your clients login, they will pick up on the .POL file and apply the policies appropriately.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#105316 - 2003-10-01 06:52 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Sparko Offline
Fresh Scripter

Registered: 2003-10-01
Posts: 6
My Kixtart logon scripts run from a Win NT BDC. I thought that they did had admin rights as they execute when users log on to the domain. Was this a misunderstanding?
Top
#105317 - 2003-10-01 07:05 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Ok, ok. MUST merge is false indeed.
Like Kent said using poledit (if there is an option for this in poledit) can also be done.
We had some problems with poledit so we sort of tossed it out the window and got hooked on merging and then writing to the newly created value.

Everyone has its own favorite [Smile]

Sparko:
So this part...

code:
if KeyExist( $poleditkey ) <> 0
$screensavetab = Readvalue($poleditkey,"NoDispScrSavPage")
if $screensavetab <> 1
WRITEVALUE($poleditkey,"NoDispScrSavPage","1","REG_DWORD")
endif
else
AddKey($poleditkey)
WRITEVALUE($poleditkey,"NoDispScrSavPage","1","REG_DWORD")
endif

...is not working.

Weird. Tested it on here and works fine. Tried to put in @error and @serror [Confused]
Looks like some kind of access denied issue.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#105318 - 2003-10-01 07:15 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
quote:
I thought that they did had admin rights as they execute when users log on to the domain. Was this a misunderstanding?
Yes, you misunderstand. The logon script runs in the context of the user. That was why GPO or POL is suggested.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#105319 - 2003-10-01 07:22 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Sparked up POLEDIT on an NT 4 Server, and picking up our Domain Policy and we find:
quote:

PolicyGroup/Control Panel/Display/Restrict display
Settings for Restrict display
_ | Deny access to display icon
X | Hide Background tab
X | Hide Screen Saver tab
X | Hide Appearance tab
_ | Hide Settings tab

HTH,

Kent

[ 01. October 2003, 19:22: Message edited by: kdyer ]
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#105320 - 2003-10-01 09:09 PM Re: ADDKEY AND WRITEVALUE PROBLEMS - SCREEN SAVER TAB DISPLAY
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
r2d2, again.
merging is not any magic.
it basically just does what you do with kixtart writing.
but to merge these areas where user has no right, neither works.
thus policies are the answer.

if you want to write with kix or merge as you wish to these keys, SU powers are needed.
_________________________
!

download KiXnet

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 657 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.178 seconds in which 0.108 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