Using wsh to edit reg 
Author Message
 Using wsh to edit reg

Hello all!  How would I use VBScript to edit an existing registry
entry?  The below is an educated guess, but I'm not sure. There are some
questions I have such as Can I use FLA's (four letter acronyms) like
HKLM? Is it really as easy as these few lines below? Is there anything
wrong with the formatting, order, or syntax?  Any help or advice is
appreciated.  TIA!

'Creating Shell Object
Set objShell=Wscript.CreateObject("Wscript.Shell")

'Writing new value to Registry
objShell.RegWrite
"HKLM\System\CurrentControlSet\Services\RCHelp\START:REG_DWORD:0x1","0x2","REG_DWORD"



Sat, 27 Nov 2004 00:08:37 GMT  
 Using wsh to edit reg
{*filter*}a,
There is a problem with your string. The HKLM is correct, but you must end
your keyname with a backslash and I do not think 0x2 is acceptable as
RE_DWORD type.

f you haven't already gotten it my I recommend the following:
http://www.*-*-*.com/
US/scrdoc56en.exe
It is excellent documentation.

Yuri


Quote:
> Hello all!  How would I use vbscript to edit an existing registry
> entry?  The below is an educated guess, but I'm not sure. There are some
> questions I have such as Can I use FLA's (four letter acronyms) like
> HKLM? Is it really as easy as these few lines below? Is there anything
> wrong with the formatting, order, or syntax?  Any help or advice is
> appreciated.  TIA!

> 'Creating Shell Object
> Set objShell=Wscript.CreateObject("Wscript.Shell")

> 'Writing new value to Registry
> objShell.RegWrite

"HKLM\System\CurrentControlSet\Services\RCHelp\START:REG_DWORD:0x1","0x2","R
EG_DWORD"


Sat, 27 Nov 2004 00:42:12 GMT  
 Using wsh to edit reg
Thanks Yuri, that did help a few of my questions looking through that
documentation, but I have more, lol.
How do I indicate which REG_DWORD value I want to change when there are multiple
REG_DWORD values under the same key (this key has Start:REG_DWORD,
Type:REG_DWORD, and ErrorControl:REG_DWORD values)?
Also, if I understand the documentation correctly, only key names need to be
ended with a backslash and not values, correct?
Quote:

> {*filter*}a,
> There is a problem with your string. The HKLM is correct, but you must end
> your keyname with a backslash and I do not think 0x2 is acceptable as
> RE_DWORD type.

> f you haven't already gotten it my I recommend the following:
> http://www.*-*-*.com/
> US/scrdoc56en.exe
> It is excellent documentation.

> Yuri



> > Hello all!  How would I use vbscript to edit an existing registry
> > entry?  The below is an educated guess, but I'm not sure. There are some
> > questions I have such as Can I use FLA's (four letter acronyms) like
> > HKLM? Is it really as easy as these few lines below? Is there anything
> > wrong with the formatting, order, or syntax?  Any help or advice is
> > appreciated.  TIA!

> > 'Creating Shell Object
> > Set objShell=Wscript.CreateObject("Wscript.Shell")

> > 'Writing new value to Registry
> > objShell.RegWrite

> "HKLM\System\CurrentControlSet\Services\RCHelp\START:REG_DWORD:0x1","0x2","R
> EG_DWORD"



Sat, 27 Nov 2004 02:49:33 GMT  
 Using wsh to edit reg
Hi {*filter*}a,

generally the syntax is as followed:

    WSHShell.RegWrite NameOfKeyOrValue, ContentOfValue, TypeOfValue.

If the first argument ist not a value but a key You have to end it with a
backslash (yes :-)) - and this means that Your Content is written to the
standard value of the key.

Test the following Example:

 set WSHShell = CreateObject("WScript.Shell")

 wshshell.regwrite "HKCR\.001\", "12", "REG_DWORD"                   ' sets
the standard value = 12 (decimal)
 wshshell.regwrite "HKCR\.001\value_string", "text", "REG_SZ"          '
sets the string variable "value_string" = "text"
 wshshell.regwrite "HKCR\.001\value_bin_1", "12", "REG_DWORD"  ' and so on
 wshshell.regwrite "HKCR\.001\value_bin_2", 13, "REG_DWORD"

Robert



Sat, 27 Nov 2004 03:51:11 GMT  
 Using wsh to edit reg
Thanks for the reply, Robert.  Call me a newbie, but I still don't understand
the answer to the following question (although I'm sure you answered it, lol).

How do I indicate which REG_DWORD value I want to change when there are
multiple REG_DWORD values under the same key (this key has Start:REG_DWORD,
Type:REG_DWORD, and ErrorControl:REG_DWORD values)?

Quote:

> Hi {*filter*}a,

> generally the syntax is as followed:

>     WSHShell.RegWrite NameOfKeyOrValue, ContentOfValue, TypeOfValue.

> If the first argument ist not a value but a key You have to end it with a
> backslash (yes :-)) - and this means that Your Content is written to the
> standard value of the key.

> Test the following Example:

>  set WSHShell = CreateObject("WScript.Shell")

>  wshshell.regwrite "HKCR\.001\", "12", "REG_DWORD"                   ' sets
> the standard value = 12 (decimal)
>  wshshell.regwrite "HKCR\.001\value_string", "text", "REG_SZ"          '
> sets the string variable "value_string" = "text"
>  wshshell.regwrite "HKCR\.001\value_bin_1", "12", "REG_DWORD"  ' and so on
>  wshshell.regwrite "HKCR\.001\value_bin_2", 13, "REG_DWORD"

> Robert



Sat, 27 Nov 2004 04:13:24 GMT  
 Using wsh to edit reg

Quote:

> Thanks for the reply, Robert.  Call me a newbie, but I still don't
> understand the answer to the following question (although I'm sure
> you answered it, lol).

> How do I indicate which REG_DWORD value I want to change when there
> are multiple REG_DWORD values under the same key (this key has
> Start:REG_DWORD, Type:REG_DWORD, and ErrorControl:REG_DWORD values)?

sKeyNameString = "HKLM\keyname\keyname\keyname\"

sValueNameString = "HKLM\keyname\keyname\keyname\valuename"

Whether the string represents a key or a named value depends simply on whether or not the string ends with a "\" (a key) or not (a named value).

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Sat, 27 Nov 2004 04:33:50 GMT  
 Using wsh to edit reg
{*filter*}a,

if I didn't missunderstand You shoud be able to set or edit the values
"start", "type" and "ErrorControl" with the following code:

 set WSHShell = CreateObject("WScript.Shell")

 wshshell.regwrite "HKLM\System\CurrentControlSet\Services\RCHelp\START",
"8", "REG_DWORD"

 wshshell.regwrite "HKLM\System\CurrentControlSet\Services\RCHelp\TYPE",
"1252", "REG_DWORD"

 wshshell.regwrite
"HKLM\System\CurrentControlSet\Services\RCHelp\ErrorControl", 45698,
"REG_DWORD"

Robert



Sat, 27 Nov 2004 04:46:15 GMT  
 Using wsh to edit reg
So, does that mean that "Start:REG_DWORD" constitutes a value name?  Is the following correct concerning keyname\valuename syntax and formatting?
Sorry for my badgering persistence, but I want to be sure I completely understand.  And Thanks soooo much!

strValueName = "HKLM\SYSTEM\CurrentControlSet\Services\RCHelp\Start:REG_DWORD"

Quote:


> > Thanks for the reply, Robert.  Call me a newbie, but I still don't
> > understand the answer to the following question (although I'm sure
> > you answered it, lol).

> > How do I indicate which REG_DWORD value I want to change when there
> > are multiple REG_DWORD values under the same key (this key has
> > Start:REG_DWORD, Type:REG_DWORD, and ErrorControl:REG_DWORD values)?

> sKeyNameString = "HKLM\keyname\keyname\keyname\"

> sValueNameString = "HKLM\keyname\keyname\keyname\valuename"

> Whether the string represents a key or a named value depends simply on whether or not the string ends with a "\" (a key) or not (a named value).

> --
> Michael Harris
> Microsoft.MVP.Scripting
> Seattle WA US
> --



Sat, 27 Nov 2004 04:51:06 GMT  
 Using wsh to edit reg
Robert, you soooooo rule!  You answered my question very clearly and simply
(something us newbies need sometimes, lol).  Thanks sooo much!
Quote:

> {*filter*}a,

> if I didn't missunderstand You shoud be able to set or edit the values
> "start", "type" and "ErrorControl" with the following code:

>  set WSHShell = CreateObject("WScript.Shell")

>  wshshell.regwrite "HKLM\System\CurrentControlSet\Services\RCHelp\START",
> "8", "REG_DWORD"

>  wshshell.regwrite "HKLM\System\CurrentControlSet\Services\RCHelp\TYPE",
> "1252", "REG_DWORD"

>  wshshell.regwrite
> "HKLM\System\CurrentControlSet\Services\RCHelp\ErrorControl", 45698,
> "REG_DWORD"

> Robert



Sat, 27 Nov 2004 04:52:44 GMT  
 Using wsh to edit reg
:-))


Sun, 28 Nov 2004 05:21:06 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Using wsh to edit reg

2. Create and Edit Files from WSH using VBScript

3. Creating and editing Access databases using WSH and VBscript

4. Using VI to edit WSH in color

5. Editing reg hives

6. reg edit

7. Custom Control for Reg Editing

8. WSH Registry Editing

9. reg exp without reg exp

10. wmi wsh script dump reg remote computer

11. wsh example of reading reg key, if/then?

12. Installing a REG file with WSH

 

 
Powered by phpBB® Forum Software