ADDING DWORD in the Registry on XP machine
Hello all,
Im only new to this forum but im having a mass headache trying to figure out how to add a REG_DWORD value to my Local machine.
What i want to have done is
1) Add a REG_DWORD value to the;
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
2) Give it a decimal value of 60
3) Give the Value name
Can anyone help? im a moderate user of the .vbs scripting but im struggling bit time on this.
Re: ADDING DWORD in the Registry on XP machine
Surelllyyyy someone out there knows.....?
Re: ADDING DWORD in the Registry on XP machine
if you google registry scripting you will get many results that will show you how set WMI as a scripting object that can read and write to local or remote registry
Re: ADDING DWORD in the Registry on XP machine
Ive tried MANY scripting google pages but the issue is not so much finding code..but getting it to work!!!!
I mean...its not hard to add a registry string (which i can do), but adding the DWORD values / string is giving me mass dramas.
Re: ADDING DWORD in the Registry on XP machine
well i googled and found some code to create as key and add string value and dword value
vb Code:
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set StdOut = WScript.StdOut
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\System Admin Scripting Guide"
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
strValueName = "String Value Name"
strValue = "string value"
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strValueName = "DWORD Value Name"
dwValue = 82
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
wscript.echo "finished " & strkeypath & strvaluename
tested!! works!!
Re: ADDING DWORD in the Registry on XP machine
arghhh how did you get it to work...? i found that code too....did you have to "tweak" anything in the code or was it just a copy and paste matter...?
Re: ADDING DWORD in the Registry on XP machine
More on what i just wrote above...i ran the script and it "seemed" to run ok. but where exsactly is the DWORD entry...? i searched the registry for "System Admin Scripting Guide" but no go...
hmmmmm
Re: ADDING DWORD in the Registry on XP machine
if you can't figure where the key is going, you should not be writing to the registry, i hope you back up your registry first
the key it creates then writes values to is hklm\SOFTWARE\System Admin Scripting Guide
i deleted the key after testing,
the only change i made to the script was to combine the creation of the key with adding the values as they were separate in the example
Re: ADDING DWORD in the Registry on XP machine
Westconn1...firstly, thanks for the insult mate. Just because i cant get a script to work doesn't mean i lack the skills in scripting. Im sorry i do not have 4000 or so posts up my sleeve. i was under the assumption that this was a forum to "help" with scripting. not insult forum members if they cannot get them working. How is someone supposed to learn if they cannot try?
and secondly, i do know where the script was writing to but it thought i would ask just to be sure as obviously its not working for me and it cant help to check.
now, is there anyone else out there that may be able to help...? maybe give us a hand with a walk through or somethingggggg? i have run that script above but NO entries are being inserted in my registry. what is it im missing? an assumption would be that its something very minor as that script is pretty self explanatory.
thanks peoples
Re: ADDING DWORD in the Registry on XP machine
I doubt that westconn1 intended anything as an insult - more a case of "cruel to be kind". One thing you may not be aware of: To write to HKLM, you need to be logged in as Admin. Even being logged in as a user with Admin priveleges may not work.
2 Attachment(s)
Re: ADDING DWORD in the Registry on XP machine
sorry you see it that way, but any instructions to make any edits to registry always (at least should be always) give warnings to back up registry first, editing registry by programming is fraught with dangers not achieving the exact result required and maybe causing some other problems
other issues with the scripting are to make sure that you have the appropriate permissions to write to that part of the registry, try changing the key to HKCU section to see if it can write there, i did get a script example, that checks permissions to the registry that i edited so that it would work with wscript as originally it was for cscript, if you want to try that i will post it
Re: ADDING DWORD in the Registry on XP machine
What OS are you trying to use this on?
EDIT - Never mind. I just looked at the title for the thread.
Re: ADDING DWORD in the Registry on XP machine
Hello all,
thanks for the replies...i got it to work but only if i created the System Admin Scripting Guide folder in the registry first...
So im a bit puzzled on why that it is. Ive ran many registry scripts before and never had any problems with the security side of things. I have local admin as well as domain admin rights.
So i guess the only thing left now is to find out WHYYY this dam folder isnt being created first...?
Re: ADDING DWORD in the Registry on XP machine
Test for an error number when creating the subkey. ie:
vb Code:
strKeyPath = "SOFTWARE\System Admin Scripting Guide"
strRet = oReg.CreateKey(HKEY_LOCAL_MACHINE,strKeyPath) '<<-- Change.
If (strRet = 0) And (Err.Number = 0) Then
Wscript.Echo "CreateKey succeeded!"
Else
Wscript.Echo "CreateKey failed. Error = " & Err.Number
End If