Solved

Adding a specific reg key via script

Posted on 2012-04-11
23
642 Views
Last Modified: 2012-04-13
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?
0
Comment
Question by:WellingtonIS
  • 14
  • 5
  • 3
  • +1
23 Comments
 
LVL 21

Expert Comment

by:motnahp00
Comment Utility
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
0
 

Author Comment

by:WellingtonIS
Comment Utility
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.
0
 
LVL 21

Expert Comment

by:motnahp00
Comment Utility
One sec...
0
 

Author Comment

by:WellingtonIS
Comment Utility
OK thanks but I can't even find that key in XP...
0
 
LVL 21

Expert Comment

by:motnahp00
Comment Utility
It should look like this:

REG ADD "HKCU\Software\Microsoft\screensavers\Text3d" /v DisplayString /t REG_SZ /d WRMC /f
0
 

Author Comment

by:WellingtonIS
Comment Utility
Hopefully it's the same in windows 7 too. Let me add to my script and see.  Thanks!!!!
0
 

Author Comment

by:WellingtonIS
Comment Utility
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%"
0
 

Author Comment

by:WellingtonIS
Comment Utility
Well I don't think I can do this remotely!  I've tried everything I can think of.
0
 
LVL 21

Expert Comment

by:motnahp00
Comment Utility
I haven't tried your method of delivery before. I typically make registry modifications via GPO or batch directly on the machine.
0
 

Author Comment

by:WellingtonIS
Comment Utility
May have to try GPO.  Not my first choice
0
 
LVL 21

Expert Comment

by:motnahp00
Comment Utility
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.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:WellingtonIS
Comment Utility
Will try thanks.
0
 

Expert Comment

by:rdiorio25
Comment Utility
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>
0
 
LVL 17

Expert Comment

by:Tony Massa
Comment Utility
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.

http://www.petri.co.il/forums/showthread.php?t=47789

You could also optionally run a script (or your batch file) by using a logon script for the user as a normal GPO.
0
 

Author Comment

by:WellingtonIS
Comment Utility
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.
0
 
LVL 17

Expert Comment

by:Tony Massa
Comment Utility
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.

http://technet.microsoft.com/en-us/library/cc976337.aspx
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
0
 

Author Comment

by:WellingtonIS
Comment Utility
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
0
 

Author Comment

by:WellingtonIS
Comment Utility
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.
0
 

Author Comment

by:WellingtonIS
Comment Utility
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?
0
 

Author Comment

by:WellingtonIS
Comment Utility
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
0
 
LVL 17

Accepted Solution

by:
Tony Massa earned 500 total points
Comment Utility
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
  Else
    strUserKey = subkey
    UpdateRegistrySettings()
  End If
Next 

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

0
 

Author Comment

by:WellingtonIS
Comment Utility
I'll give it a shot.  Thanks
0
 

Author Closing Comment

by:WellingtonIS
Comment Utility
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.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

One of the features I've come to appreciate about Windows 7 and Windows Server 2008 R2 is the ability to pin applications to the task bar. As useful a feature as I've found this, it does have some quirks.  For example, have you ever tried pinning an…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now