25 pts.
 Copy Registry key using VBS Script
Hi, I have a question i'm trying to copy the PC name witch is located in (HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlComputerNameComputerName)  to a different registry key (HKEY_LOCAL_MACHINESOFTWAREIOLANSphereStation) but i can't get it to work. I thought is should work with the script posted below but is doesn't it gives no error.
Set WshShell = Wscript.CreateObject("Wscript.Shell")

'Read the value of DefaultUserName :
reg = WSHShell.RegRead ("HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlComputerNameComputerNameComputerName")

'Replace the value with "Id" :
WshShell.RegWrite ("HKEY_LOCAL_MACHINESOFTWAREIOLANSphereStation"), "Id" ,"REG_SZ"

'Data Types :
'REG_DWORD
'REG_BINARY
'REG_EXPAND_SZ
As you probable already noticed i havent got that mutch experience with VBS Scripting. I hope you guys can help me out al little.

Software/Hardware used:
Windows Xp Sp3
ASKED: December 9, 2009  3:10 PM
UPDATED: December 18, 2009  12:48 AM

Answer Wiki:
Try running reg from a command line. You could call from VBScript if you need to use VBScript. <pre>cmd /c reg add "HKLMkey" /v VALUE /t REG_SZ /d %COMPUTERNAME% /F</pre> Unfortunately your "<pre></pre>" (backslash) characters were stripped. Use the "code" tags around your script sections to prevent them from being stripped.
Last Wiki Answer Submitted:  December 16, 2009  3:37 pm  by  Com   75 pts.
All Answer Wiki Contributors:  Com   75 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

I can read, the information from the registry using…

reg query “HKLMSYSTEMCurrentControlSetControlComputerNameComputerName” /v “ComputerName”

and i can also simply add the information to the registry but i want to automate it (Run Once at system start up)

The reason i want to automate this is because i have to clone a lot of PC’s and each one uses its PC name to logon to our companies software, having to edit every PC’s registry to add this information to the registry consumes a lot of time.

So if anyone knows of a way to do this, your help would be greatly appreciated.

 25 pts.

 

Is there any reason you cannot use the COMPUTERNAME environment variable?

 3,310 pts.

 

It works TnX Pjb0222… :)

 25 pts.