|
-
Sep 16th, 2007, 09:33 PM
#1
Thread Starter
New Member
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.
-
Sep 17th, 2007, 05:59 PM
#2
Thread Starter
New Member
Re: ADDING DWORD in the Registry on XP machine
Surelllyyyy someone out there knows.....?
-
Sep 18th, 2007, 07:26 AM
#3
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 18th, 2007, 06:11 PM
#4
Thread Starter
New Member
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.
-
Sep 19th, 2007, 06:52 AM
#5
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!!
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 19th, 2007, 07:30 PM
#6
Thread Starter
New Member
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...?
-
Sep 19th, 2007, 07:36 PM
#7
Thread Starter
New Member
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
-
Sep 19th, 2007, 10:13 PM
#8
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 19th, 2007, 10:34 PM
#9
Thread Starter
New Member
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
-
Sep 20th, 2007, 04:06 AM
#10
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.
-
Sep 20th, 2007, 04:07 AM
#11
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 20th, 2007, 05:48 AM
#12
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.
Last edited by MarkT; Sep 20th, 2007 at 07:45 AM.
-
Sep 20th, 2007, 05:28 PM
#13
Thread Starter
New Member
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...?
-
Sep 21st, 2007, 03:38 AM
#14
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|