Adding a specific reg key via script

I have a script but I want to edit the DisplayString to the following key:
HKEY_Current_User\Software\Microsoft\screensavers\Text3d  the key that I want to modify is DisplayString (REG_SZ) - I want to change from Microsoft Windows to WRMC.

Just now sure how to modify the displaystring part.  Can someone help with the words?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Here's an example for you to go off of:

REG ADD "HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop" /v ScreenSaveActive /t REG_SZ /d 1 /f
WellingtonISAuthor Commented:
Can I replace the 1 with WRMC?  Not sure how to do this.  I'm just looking at the actual Key I want to modify.
One sec...
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

WellingtonISAuthor Commented:
OK thanks but I can't even find that key in XP...
It should look like this:

REG ADD "HKCU\Software\Microsoft\screensavers\Text3d" /v DisplayString /t REG_SZ /d WRMC /f
WellingtonISAuthor Commented:
Hopefully it's the same in windows 7 too. Let me add to my script and see.  Thanks!!!!
WellingtonISAuthor Commented:
OK what I've done is create a bat file with the key you gave me.  And though Psexec copy the bat file to the hard drive, call the bat file and delete the bat file.  all well and good but it's not copying the info to the registry unless I'm doing it on the machine directly!

@echo off
set /p var= Enter Computer Name:
set /p var2=Enter the File Name:

Psexec \\%var% -s cmd /c copy "\\computername\sharename\%var2%" c:\

psexec \\%var% -s cmd /c c:\%Var2% /q

psexec  \\%var% -s cmd /c del "c:\%var2%"
WellingtonISAuthor Commented:
Well I don't think I can do this remotely!  I've tried everything I can think of.
I haven't tried your method of delivery before. I typically make registry modifications via GPO or batch directly on the machine.
WellingtonISAuthor Commented:
May have to try GPO.  Not my first choice
I think it's better through GPO. This way you revert to your original setting(s) when you pull your machine outside the GP scope.
WellingtonISAuthor Commented:
Will try thanks.
Not sure if you tried this, the example above did not have the appropriate path to the key.

REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Screensavers\ssText3d" /v DisplayString /t REG_SZ /d WRMC /f

copy reg to remote machine, then execute with this.
psexec \\<computer1> -d -c regedit /s <file.reg>
Tony MassaCommented:
You can remotely write to a computer's registry; however, you can't easily write to "HKEY_CURRENT_USER"

If you install the Client Side Extensions for XP, and you have a 2008 domain controller, you can achieve this with Group Policy Preferences in AD.

You could also optionally run a script (or your batch file) by using a logon script for the user as a normal GPO.
WellingtonISAuthor Commented:
OK I don't have 2008 yet so not an option.  I hate to do another logon script but we'll see.  I'm having a heck of a time. but I'm still testing.  I'm trying to write under the system account but it's just not working.  I have the 2008 tools for GPO's so I'm going to try to add t the registry like that 1st.  If not last resort is the logon script.
Tony MassaCommented:
System account has the permissions, but HKey_Current_User is not an actual path in the registry.  It's a link to the HKEY_Users_<user's objectSid> key.
The HKEY_CURRENT USER subtree does not contain any data. It just stores a pointer to the content of the HKEY_USERS\ Security ID (SID) of current user subkey. Therefore, the content of that subkey also appear in HKEY_CURRENT_USER, and it can be viewed and changed in either location. This subtree provides easier access to the data.
So if you're running a script as SYSTEM, you won't be able to write to the HKCU tree, you would have to write to the HKEY_USERS_<USER SID> reg path
WellingtonISAuthor Commented:
OK if that's the case then I'd need to find the user sid - and then add this key REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Screensavers\ssText3d" /v DisplayString /t REG_SZ /d WRMC /f?  I can do that remotely but I just want to make sure that's what this means
WellingtonISAuthor Commented:
I think I actually did it by using the 2008 group policy tools and adding the registry key.  I'm going to check on it later today.
WellingtonISAuthor Commented:
OK it didn't work putting the registry setting in the GPO in AD.  OK so back to what you were saying.  I wonder if I can configure the registry key for all users in  a GPO?
WellingtonISAuthor Commented:
OK I tried by finding the user's sid connected to the registry and adding the display string.  WRMC to the Screen Savers Text 3D Screen.  It didn't work
Tony MassaCommented:
Not sure if this will help, but here's a script I wrote that will enumerate all domain/local user profiles on a computer with a registry change.  You can run this as a local administrator or under SYSTEM account for computer startup script.  I pulled this from another script I had working, so you'll want to test on a test PC.

On Error Resume Next
const HKEY_LOCAL_MACHINE = &H80000002 
Const HKEY_USERS = &H80000003 'HKEY_USERS 

strComputer = "." 

Set objReg=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv") 
objReg.EnumKey HKEY_USERS, "", arrSubKeys 

For Each subkey In arrSubKeys
  If right(subKey, 8) = "_Classes" or Len(subKey) < 10 Then
    'Do Nothing
    strUserKey = subkey
  End If

Function UpdateRegistrySettings()
  x = x + 1
  strKeyPath = strUserKey & "\Software\Microsoft\Windows\CurrentVersion\Screensavers\ssText3d"

  strValueName = "DisplayString"
  strValue = "WRMC"
  objReg.SetStringValue HKEY_Users, strKeyPath, strValueName, strValue
End Function

WScript.Echo x & " profiles processed"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
WellingtonISAuthor Commented:
I'll give it a shot.  Thanks
WellingtonISAuthor Commented:
What I actually wound up doing is using this as a bat file copying it into all users startup and letting run that way.  It's changing the registry and the screensaver is finally showing the words WRMC.  thanks for all the help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows XP

From novice to tech pro — start learning today.