Results 1 to 14 of 14

Thread: ADDING DWORD in the Registry on XP machine

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    7

    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.

  2. #2

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    7

    Re: ADDING DWORD in the Registry on XP machine

    Surelllyyyy someone out there knows.....?

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    7

    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.

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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:
    1. const HKEY_LOCAL_MACHINE = &H80000002
    2. strComputer = "."
    3. Set StdOut = WScript.StdOut
    4.  
    5. Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
    6. strComputer & "\root\default:StdRegProv")
    7.  
    8. strKeyPath = "SOFTWARE\System Admin Scripting Guide"
    9. oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
    10. strValueName = "String Value Name"
    11. strValue = "string value"
    12. oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
    13.  
    14. strValueName = "DWORD Value Name"
    15. dwValue = 82
    16. oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
    17. 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

  6. #6

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    7

    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...?

  7. #7

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    7

    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

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  9. #9

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    7

    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

  10. #10
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    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.

  11. #11
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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
    Attached Images Attached Images   
    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

  12. #12
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    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.

  13. #13

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    7

    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...?

  14. #14
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: ADDING DWORD in the Registry on XP machine

    Test for an error number when creating the subkey. ie:

    vb Code:
    1. strKeyPath = "SOFTWARE\System Admin Scripting Guide"
    2. strRet = oReg.CreateKey(HKEY_LOCAL_MACHINE,strKeyPath) '<<-- Change.
    3.  
    4. If (strRet = 0) And (Err.Number = 0) Then
    5.    Wscript.Echo "CreateKey succeeded!"
    6. Else
    7.    Wscript.Echo "CreateKey failed. Error = " & Err.Number
    8. 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
  •  



Click Here to Expand Forum to Full Width