Solved

Adding a specific reg key via script

Posted on 2012-04-11
23
653 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 14
  • 5
  • 3
  • +1
23 Comments
 
LVL 21

Expert Comment

by:motnahp00
ID: 37833525
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
ID: 37833584
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
ID: 37833660
One sec...
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

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

Expert Comment

by:motnahp00
ID: 37833675
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
ID: 37833689
Hopefully it's the same in windows 7 too. Let me add to my script and see.  Thanks!!!!
0
 

Author Comment

by:WellingtonIS
ID: 37833761
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
ID: 37833877
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
ID: 37833890
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
ID: 37834052
May have to try GPO.  Not my first choice
0
 
LVL 21

Expert Comment

by:motnahp00
ID: 37834073
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
 

Author Comment

by:WellingtonIS
ID: 37834140
Will try thanks.
0
 

Expert Comment

by:rdiorio25
ID: 37834469
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
ID: 37834504
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
ID: 37834746
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
ID: 37834982
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
ID: 37837077
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
ID: 37837408
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
ID: 37837684
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
ID: 37837767
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
ID: 37838275
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
ID: 37838399
I'll give it a shot.  Thanks
0
 

Author Closing Comment

by:WellingtonIS
ID: 37842409
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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
On some Windows 7 (SP1) computers, Windows Update becomes super slow even the computer is reasonably fast.  There's one solution that seemed to have worked well for me (after trying a few other suggested solutions).
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

691 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