Problems using RegRead Method 
Author Message
 Problems using RegRead Method

I am having some trouble trying to read certain values from the Windows 98
Registry. I have read the WSH documentation from MS and have found that
RegRead works only with certain data types. I keep getting Type Mismatch
errors when I try to read the following value:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore
r\NoDriveTypeAutoRun

The value shows up as 95 00 00 00 when using Regedit. There are no quotes
around the data, it is a numeric data type of some kind. I need to be able
to read this information and change it if necessary.

I am assuming this is a limitation of WSH, but there has got to be another
way to get this information into/out of the registry using scripting.

If anyone knows of a method to read and write this type of data from and to
the registry using VBScript and/or WSH, your help would be GREATLY
APPRECIATED!

TIA,

Kenny



Mon, 27 Jan 2003 03:00:00 GMT  
 Problems using RegRead Method
Looks like a 4 byte REG_BINARY value.

When you RegRead any key or named value with a REG_BINARY value, you get an array of variants of
subtype byte with one element per byte.  This is for WSH 2.0 - WSH 1.0 gave you an array of bytes
(not variants of subtype byte) that was much more difficult to deal with...

--
Michael Harris
Microsoft MVP - Scripting


Quote:
> I am having some trouble trying to read certain values from the Windows 98
> Registry. I have read the WSH documentation from MS and have found that
> RegRead works only with certain data types. I keep getting Type Mismatch
> errors when I try to read the following value:

> HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore
> r\NoDriveTypeAutoRun

> The value shows up as 95 00 00 00 when using Regedit. There are no quotes
> around the data, it is a numeric data type of some kind. I need to be able
> to read this information and change it if necessary.

> I am assuming this is a limitation of WSH, but there has got to be another
> way to get this information into/out of the registry using scripting.

> If anyone knows of a method to read and write this type of data from and to
> the registry using VBScript and/or WSH, your help would be GREATLY
> APPRECIATED!

> TIA,

> Kenny



Mon, 27 Jan 2003 03:00:00 GMT  
 Problems using RegRead Method
Thanks for the explanation Michael,

I guess what I need to know is how to code a RegRead that will get these 4
bytes of data. I tried using an array and still get Type Mismatch. Thanks
for any advice you can provide.

Kenny


Quote:
> Looks like a 4 byte REG_BINARY value.

> When you RegRead any key or named value with a REG_BINARY value, you get

an array of variants of
Quote:
> subtype byte with one element per byte.  This is for WSH 2.0 - WSH 1.0

gave you an array of bytes
Quote:
> (not variants of subtype byte) that was much more difficult to deal
with...

> --
> Michael Harris
> Microsoft MVP - Scripting



> > I am having some trouble trying to read certain values from the Windows
98
> > Registry. I have read the WSH documentation from MS and have found that
> > RegRead works only with certain data types. I keep getting Type Mismatch
> > errors when I try to read the following value:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore

- Show quoted text -

Quote:
> > r\NoDriveTypeAutoRun

> > The value shows up as 95 00 00 00 when using Regedit. There are no
quotes
> > around the data, it is a numeric data type of some kind. I need to be
able
> > to read this information and change it if necessary.

> > I am assuming this is a limitation of WSH, but there has got to be
another
> > way to get this information into/out of the registry using scripting.

> > If anyone knows of a method to read and write this type of data from and
to
> > the registry using VBScript and/or WSH, your help would be GREATLY
> > APPRECIATED!

> > TIA,

> > Kenny



Mon, 27 Jan 2003 03:00:00 GMT  
 Problems using RegRead Method

This works for WSH 2.0 (WScript.Version -> 5.1)...

set shell = createobject("wscript.shell")
sKey = "HKEY_CURRENT_USER\Software\"_
     & "Microsoft\Windows\CurrentVersion\"_
     & "Policies\Explorer\"
sVal = "NoDriveTypeAutoRun"

arBytes = shell.RegRead(sKey & sVal)

for each byt in arBytes
  s = s & right("0" & hex(byt),2) & " "
next

msgbox s

--
Michael Harris
Microsoft MVP - Scripting

"It always helps to read the documentation..."


Quote:
> Thanks for the explanation Michael,

> I guess what I need to know is how to code a RegRead that will get these 4
> bytes of data. I tried using an array and still get Type Mismatch. Thanks
> for any advice you can provide.

> Kenny



> > Looks like a 4 byte REG_BINARY value.

> > When you RegRead any key or named value with a REG_BINARY value, you get
> an array of variants of
> > subtype byte with one element per byte.  This is for WSH 2.0 - WSH 1.0
> gave you an array of bytes
> > (not variants of subtype byte) that was much more difficult to deal
> with...

> > --
> > Michael Harris
> > Microsoft MVP - Scripting



> > > I am having some trouble trying to read certain values from the Windows
> 98
> > > Registry. I have read the WSH documentation from MS and have found that
> > > RegRead works only with certain data types. I keep getting Type Mismatch
> > > errors when I try to read the following value:

> HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore
> > > r\NoDriveTypeAutoRun

> > > The value shows up as 95 00 00 00 when using Regedit. There are no
> quotes
> > > around the data, it is a numeric data type of some kind. I need to be
> able
> > > to read this information and change it if necessary.

> > > I am assuming this is a limitation of WSH, but there has got to be
> another
> > > way to get this information into/out of the registry using scripting.

> > > If anyone knows of a method to read and write this type of data from and
> to
> > > the registry using VBScript and/or WSH, your help would be GREATLY
> > > APPRECIATED!

> > > TIA,

> > > Kenny



Mon, 27 Jan 2003 03:00:00 GMT  
 Problems using RegRead Method
Michael,

The code example you gave works like a champ for reading, I see how it reads
in to an Array of bytes, and how to format a display of the bytes.

Now the final part of the puzzle.....

How to assign a new 4 byte value to that key.

For example, instead of 95 00 00 00
I want to write 00 00 00 00 (And it has to show up in the registry as
numbers, not a string)

I tried writing arBytes back to the same key, but again, type mismatch.

Thanks for all your help!

kenny


Quote:
> This works for WSH 2.0 (WScript.Version -> 5.1)...

> set shell = createobject("wscript.shell")
> sKey = "HKEY_CURRENT_USER\Software\"_
>      & "Microsoft\Windows\CurrentVersion\"_
>      & "Policies\Explorer\"
> sVal = "NoDriveTypeAutoRun"

> arBytes = shell.RegRead(sKey & sVal)

> for each byt in arBytes
>   s = s & right("0" & hex(byt),2) & " "
> next

> msgbox s

> --
> Michael Harris
> Microsoft MVP - Scripting

> "It always helps to read the documentation..."



> > Thanks for the explanation Michael,

> > I guess what I need to know is how to code a RegRead that will get these
4
> > bytes of data. I tried using an array and still get Type Mismatch.
Thanks
> > for any advice you can provide.

> > Kenny



> > > Looks like a 4 byte REG_BINARY value.

> > > When you RegRead any key or named value with a REG_BINARY value, you
get
> > an array of variants of
> > > subtype byte with one element per byte.  This is for WSH 2.0 - WSH 1.0
> > gave you an array of bytes
> > > (not variants of subtype byte) that was much more difficult to deal
> > with...

> > > --
> > > Michael Harris
> > > Microsoft MVP - Scripting



> > > > I am having some trouble trying to read certain values from the
Windows
> > 98
> > > > Registry. I have read the WSH documentation from MS and have found
that
> > > > RegRead works only with certain data types. I keep getting Type
Mismatch
> > > > errors when I try to read the following value:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore

- Show quoted text -

Quote:
> > > > r\NoDriveTypeAutoRun

> > > > The value shows up as 95 00 00 00 when using Regedit. There are no
> > quotes
> > > > around the data, it is a numeric data type of some kind. I need to
be
> > able
> > > > to read this information and change it if necessary.

> > > > I am assuming this is a limitation of WSH, but there has got to be
> > another
> > > > way to get this information into/out of the registry using
scripting.

> > > > If anyone knows of a method to read and write this type of data from
and
> > to
> > > > the registry using VBScript and/or WSH, your help would be GREATLY
> > > > APPRECIATED!

> > > > TIA,

> > > > Kenny



Mon, 27 Jan 2003 03:00:00 GMT  
 Problems using RegRead Method
You can only RegWrite a REG_BINARY value from a Long...

set shell = createobject("wscript.shell")
sKey = "HKEY_CURRENT_USER\Software\"_
     & "Microsoft\Windows\CurrentVersion\"_
     & "Policies\Explorer\"
sVal = "NoDriveTypeAutoRun"

shell.RegWrite sKey & sVal, CLng(0), "REG_BINARY"

--
Michael Harris
Microsoft MVP - Scripting

"It always helps to read the documentation..."


Quote:
> Michael,

> The code example you gave works like a champ for reading, I see how it reads
> in to an Array of bytes, and how to format a display of the bytes.

> Now the final part of the puzzle.....

> How to assign a new 4 byte value to that key.

> For example, instead of 95 00 00 00
> I want to write 00 00 00 00 (And it has to show up in the registry as
> numbers, not a string)

> I tried writing arBytes back to the same key, but again, type mismatch.

> Thanks for all your help!

> kenny



> > This works for WSH 2.0 (WScript.Version -> 5.1)...

> > set shell = createobject("wscript.shell")
> > sKey = "HKEY_CURRENT_USER\Software\"_
> >      & "Microsoft\Windows\CurrentVersion\"_
> >      & "Policies\Explorer\"
> > sVal = "NoDriveTypeAutoRun"

> > arBytes = shell.RegRead(sKey & sVal)

> > for each byt in arBytes
> >   s = s & right("0" & hex(byt),2) & " "
> > next

> > msgbox s

> > --
> > Michael Harris
> > Microsoft MVP - Scripting

> > "It always helps to read the documentation..."



> > > Thanks for the explanation Michael,

> > > I guess what I need to know is how to code a RegRead that will get these
> 4
> > > bytes of data. I tried using an array and still get Type Mismatch.
> Thanks
> > > for any advice you can provide.

> > > Kenny



> > > > Looks like a 4 byte REG_BINARY value.

> > > > When you RegRead any key or named value with a REG_BINARY value, you
> get
> > > an array of variants of
> > > > subtype byte with one element per byte.  This is for WSH 2.0 - WSH 1.0
> > > gave you an array of bytes
> > > > (not variants of subtype byte) that was much more difficult to deal
> > > with...

> > > > --
> > > > Michael Harris
> > > > Microsoft MVP - Scripting



> > > > > I am having some trouble trying to read certain values from the
> Windows
> > > 98
> > > > > Registry. I have read the WSH documentation from MS and have found
> that
> > > > > RegRead works only with certain data types. I keep getting Type
> Mismatch
> > > > > errors when I try to read the following value:

> HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore
> > > > > r\NoDriveTypeAutoRun

> > > > > The value shows up as 95 00 00 00 when using Regedit. There are no
> > > quotes
> > > > > around the data, it is a numeric data type of some kind. I need to
> be
> > > able
> > > > > to read this information and change it if necessary.

> > > > > I am assuming this is a limitation of WSH, but there has got to be
> > > another
> > > > > way to get this information into/out of the registry using
> scripting.

> > > > > If anyone knows of a method to read and write this type of data from
> and
> > > to
> > > > > the registry using VBScript and/or WSH, your help would be GREATLY
> > > > > APPRECIATED!

> > > > > TIA,

> > > > > Kenny



Mon, 27 Jan 2003 03:00:00 GMT  
 Problems using RegRead Method
To expand a bit...

Suppose you wanted to set the value back to "95 00 00 00".  The way you do that is not entirely
intuitive since to you need to pass a long value.

newVal = CLng(&h00000095)

set shell = createobject("wscript.shell")
sKey = "HKEY_CURRENT_USER\Software\"_
     & "Microsoft\Windows\CurrentVersion\"_
     & "Policies\Explorer\"
sVal = "NoDriveTypeAutoRun"

shell.RegWrite sKey & sVal, newVal, "REG_BINARY"

In general, to get a REG_BINARY value of "aa bb cc dd" (as displayed by RegEdit - the embedded
spaces are only for display) you need to define the hex string passed to CLng() with the bytes
reversed.

newVal = CLng(&hddccbbaa)

When written as a REG_BINARY value, this will appear in RegEdit as "aa bb cc dd".

--
Michael Harris
MVP Scripting

"It always helps to read the documentation first..."

You can only RegWrite a REG_BINARY value from a Long...

set shell = createobject("wscript.shell")
sKey = "HKEY_CURRENT_USER\Software\"_
     & "Microsoft\Windows\CurrentVersion\"_
     & "Policies\Explorer\"
sVal = "NoDriveTypeAutoRun"

shell.RegWrite sKey & sVal, CLng(0), "REG_BINARY"

--
Michael Harris
Microsoft MVP - Scripting

"It always helps to read the documentation first..."


Quote:
> Michael,

> The code example you gave works like a champ for reading, I see how it reads
> in to an Array of bytes, and how to format a display of the bytes.

> Now the final part of the puzzle.....

> How to assign a new 4 byte value to that key.

> For example, instead of 95 00 00 00
> I want to write 00 00 00 00 (And it has to show up in the registry as
> numbers, not a string)

> I tried writing arBytes back to the same key, but again, type mismatch.

> Thanks for all your help!

> kenny



> > This works for WSH 2.0 (WScript.Version -> 5.1)...

> > set shell = createobject("wscript.shell")
> > sKey = "HKEY_CURRENT_USER\Software\"_
> >      & "Microsoft\Windows\CurrentVersion\"_
> >      & "Policies\Explorer\"
> > sVal = "NoDriveTypeAutoRun"

> > arBytes = shell.RegRead(sKey & sVal)

> > for each byt in arBytes
> >   s = s & right("0" & hex(byt),2) & " "
> > next

> > msgbox s

> > --
> > Michael Harris
> > Microsoft MVP - Scripting

> > "It always helps to read the documentation..."



> > > Thanks for the explanation Michael,

> > > I guess what I need to know is how to code a RegRead that will get these
> 4
> > > bytes of data. I tried using an array and still get Type Mismatch.
> Thanks
> > > for any advice you can provide.

> > > Kenny



> > > > Looks like a 4 byte REG_BINARY value.

> > > > When you RegRead any key or named value with a REG_BINARY value, you
> get
> > > an array of variants of
> > > > subtype byte with one element per byte.  This is for WSH 2.0 - WSH 1.0
> > > gave you an array of bytes
> > > > (not variants of subtype byte) that was much more difficult to deal
> > > with...

> > > > --
> > > > Michael Harris
> > > > Microsoft MVP - Scripting



> > > > > I am having some trouble trying to read certain values from the
> Windows
> > > 98
> > > > > Registry. I have read the WSH documentation from MS and have found
> that
> > > > > RegRead works only with certain data types. I keep getting Type
> Mismatch
> > > > > errors when I try to read the following value:

> HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore
> > > > > r\NoDriveTypeAutoRun

> > > > > The value shows up as 95 00 00 00 when using Regedit. There are no
> > > quotes
> > > > > around the data, it is a numeric data type of some kind. I need to
> be
> > > able
> > > > > to read this information and change it if necessary.

> > > > > I am assuming this is a limitation of WSH, but there has got to be
> > > another
> > > > > way to get this information into/out of the registry using
> scripting.

> > > > > If anyone knows of a method to read and write this type of data from
> and
> > > to
> > > > > the registry using VBScript and/or WSH, your help would be GREATLY
> > > > > APPRECIATED!

> > > > > TIA,

> > > > > Kenny



Tue, 28 Jan 2003 03:00:00 GMT  
 Problems using RegRead Method
Michael,

I can get it to write only 1 byte to the key. As I perform consecutive
RegWrite, it overwrites the first byte instead of adding them on. Is it
impossible to write all 4 bytes?

Thanks again,

Ken


Quote:
> You can only RegWrite a REG_BINARY value from a Long...

> set shell = createobject("wscript.shell")
> sKey = "HKEY_CURRENT_USER\Software\"_
>      & "Microsoft\Windows\CurrentVersion\"_
>      & "Policies\Explorer\"
> sVal = "NoDriveTypeAutoRun"

> shell.RegWrite sKey & sVal, CLng(0), "REG_BINARY"

> --
> Michael Harris
> Microsoft MVP - Scripting

> "It always helps to read the documentation..."



> > Michael,

> > The code example you gave works like a champ for reading, I see how it
reads
> > in to an Array of bytes, and how to format a display of the bytes.

> > Now the final part of the puzzle.....

> > How to assign a new 4 byte value to that key.

> > For example, instead of 95 00 00 00
> > I want to write 00 00 00 00 (And it has to show up in the registry as
> > numbers, not a string)

> > I tried writing arBytes back to the same key, but again, type mismatch.

> > Thanks for all your help!

> > kenny



> > > This works for WSH 2.0 (WScript.Version -> 5.1)...

> > > set shell = createobject("wscript.shell")
> > > sKey = "HKEY_CURRENT_USER\Software\"_
> > >      & "Microsoft\Windows\CurrentVersion\"_
> > >      & "Policies\Explorer\"
> > > sVal = "NoDriveTypeAutoRun"

> > > arBytes = shell.RegRead(sKey & sVal)

> > > for each byt in arBytes
> > >   s = s & right("0" & hex(byt),2) & " "
> > > next

> > > msgbox s

> > > --
> > > Michael Harris
> > > Microsoft MVP - Scripting

> > > "It always helps to read the documentation..."



> > > > Thanks for the explanation Michael,

> > > > I guess what I need to know is how to code a RegRead that will get
these
> > 4
> > > > bytes of data. I tried using an array and still get Type Mismatch.
> > Thanks
> > > > for any advice you can provide.

> > > > Kenny



> > > > > Looks like a 4 byte REG_BINARY value.

> > > > > When you RegRead any key or named value with a REG_BINARY value,
you
> > get
> > > > an array of variants of
> > > > > subtype byte with one element per byte.  This is for WSH 2.0 - WSH
1.0
> > > > gave you an array of bytes
> > > > > (not variants of subtype byte) that was much more difficult to
deal
> > > > with...

> > > > > --
> > > > > Michael Harris
> > > > > Microsoft MVP - Scripting


message

> > > > > > I am having some trouble trying to read certain values from the
> > Windows
> > > > 98
> > > > > > Registry. I have read the WSH documentation from MS and have
found
> > that
> > > > > > RegRead works only with certain data types. I keep getting Type
> > Mismatch
> > > > > > errors when I try to read the following value:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore

- Show quoted text -

Quote:
> > > > > > r\NoDriveTypeAutoRun

> > > > > > The value shows up as 95 00 00 00 when using Regedit. There are
no
> > > > quotes
> > > > > > around the data, it is a numeric data type of some kind. I need
to
> > be
> > > > able
> > > > > > to read this information and change it if necessary.

> > > > > > I am assuming this is a limitation of WSH, but there has got to
be
> > > > another
> > > > > > way to get this information into/out of the registry using
> > scripting.

> > > > > > If anyone knows of a method to read and write this type of data
from
> > and
> > > > to
> > > > > > the registry using VBScript and/or WSH, your help would be
GREATLY
> > > > > > APPRECIATED!

> > > > > > TIA,

> > > > > > Kenny



Tue, 28 Jan 2003 03:00:00 GMT  
 Problems using RegRead Method
See my previous reply on this thread...

--
Michael Harris
MVP Scripting

"It always helps to read the documentation first..."


Michael,

I can get it to write only 1 byte to the key. As I perform consecutive
RegWrite, it overwrites the first byte instead of adding them on. Is it
impossible to write all 4 bytes?

Thanks again,

Ken


Quote:
> You can only RegWrite a REG_BINARY value from a Long...

> set shell = createobject("wscript.shell")
> sKey = "HKEY_CURRENT_USER\Software\"_
>      & "Microsoft\Windows\CurrentVersion\"_
>      & "Policies\Explorer\"
> sVal = "NoDriveTypeAutoRun"

> shell.RegWrite sKey & sVal, CLng(0), "REG_BINARY"

> --
> Michael Harris
> Microsoft MVP - Scripting

> "It always helps to read the documentation..."



> > Michael,

> > The code example you gave works like a champ for reading, I see how it
reads
> > in to an Array of bytes, and how to format a display of the bytes.

> > Now the final part of the puzzle.....

> > How to assign a new 4 byte value to that key.

> > For example, instead of 95 00 00 00
> > I want to write 00 00 00 00 (And it has to show up in the registry as
> > numbers, not a string)

> > I tried writing arBytes back to the same key, but again, type mismatch.

> > Thanks for all your help!

> > kenny



> > > This works for WSH 2.0 (WScript.Version -> 5.1)...

> > > set shell = createobject("wscript.shell")
> > > sKey = "HKEY_CURRENT_USER\Software\"_
> > >      & "Microsoft\Windows\CurrentVersion\"_
> > >      & "Policies\Explorer\"
> > > sVal = "NoDriveTypeAutoRun"

> > > arBytes = shell.RegRead(sKey & sVal)

> > > for each byt in arBytes
> > >   s = s & right("0" & hex(byt),2) & " "
> > > next

> > > msgbox s

> > > --
> > > Michael Harris
> > > Microsoft MVP - Scripting

> > > "It always helps to read the documentation..."



> > > > Thanks for the explanation Michael,

> > > > I guess what I need to know is how to code a RegRead that will get
these
> > 4
> > > > bytes of data. I tried using an array and still get Type Mismatch.
> > Thanks
> > > > for any advice you can provide.

> > > > Kenny



> > > > > Looks like a 4 byte REG_BINARY value.

> > > > > When you RegRead any key or named value with a REG_BINARY value,
you
> > get
> > > > an array of variants of
> > > > > subtype byte with one element per byte.  This is for WSH 2.0 - WSH
1.0
> > > > gave you an array of bytes
> > > > > (not variants of subtype byte) that was much more difficult to
deal
> > > > with...

> > > > > --
> > > > > Michael Harris
> > > > > Microsoft MVP - Scripting


message

> > > > > > I am having some trouble trying to read certain values from the
> > Windows
> > > > 98
> > > > > > Registry. I have read the WSH documentation from MS and have
found
> > that
> > > > > > RegRead works only with certain data types. I keep getting Type
> > Mismatch
> > > > > > errors when I try to read the following value:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore

- Show quoted text -

Quote:
> > > > > > r\NoDriveTypeAutoRun

> > > > > > The value shows up as 95 00 00 00 when using Regedit. There are
no
> > > > quotes
> > > > > > around the data, it is a numeric data type of some kind. I need
to
> > be
> > > > able
> > > > > > to read this information and change it if necessary.

> > > > > > I am assuming this is a limitation of WSH, but there has got to
be
> > > > another
> > > > > > way to get this information into/out of the registry using
> > scripting.

> > > > > > If anyone knows of a method to read and write this type of data
from
> > and
> > > > to
> > > > > > the registry using VBScript and/or WSH, your help would be
GREATLY
> > > > > > APPRECIATED!

> > > > > > TIA,

> > > > > > Kenny



Tue, 28 Jan 2003 03:00:00 GMT  
 Problems using RegRead Method
Michael,

Thank you for your quick responses. This is excellent!

Kenny


Quote:
> To expand a bit...

> Suppose you wanted to set the value back to "95 00 00 00".  The way you do

that is not entirely
Quote:
> intuitive since to you need to pass a long value.

> newVal = CLng(&h00000095)

> set shell = createobject("wscript.shell")
> sKey = "HKEY_CURRENT_USER\Software\"_
>      & "Microsoft\Windows\CurrentVersion\"_
>      & "Policies\Explorer\"
> sVal = "NoDriveTypeAutoRun"

> shell.RegWrite sKey & sVal, newVal, "REG_BINARY"

> In general, to get a REG_BINARY value of "aa bb cc dd" (as displayed by

RegEdit - the embedded
Quote:
> spaces are only for display) you need to define the hex string passed to

CLng() with the bytes
Quote:
> reversed.

> newVal = CLng(&hddccbbaa)

> When written as a REG_BINARY value, this will appear in RegEdit as "aa bb
cc dd".

> --
> Michael Harris
> MVP Scripting

> "It always helps to read the documentation first..."




Quote:
> You can only RegWrite a REG_BINARY value from a Long...

> set shell = createobject("wscript.shell")
> sKey = "HKEY_CURRENT_USER\Software\"_
>      & "Microsoft\Windows\CurrentVersion\"_
>      & "Policies\Explorer\"
> sVal = "NoDriveTypeAutoRun"

> shell.RegWrite sKey & sVal, CLng(0), "REG_BINARY"

> --
> Michael Harris
> Microsoft MVP - Scripting

> "It always helps to read the documentation first..."



> > Michael,

> > The code example you gave works like a champ for reading, I see how it
reads
> > in to an Array of bytes, and how to format a display of the bytes.

> > Now the final part of the puzzle.....

> > How to assign a new 4 byte value to that key.

> > For example, instead of 95 00 00 00
> > I want to write 00 00 00 00 (And it has to show up in the registry as
> > numbers, not a string)

> > I tried writing arBytes back to the same key, but again, type mismatch.

> > Thanks for all your help!

> > kenny



> > > This works for WSH 2.0 (WScript.Version -> 5.1)...

> > > set shell = createobject("wscript.shell")
> > > sKey = "HKEY_CURRENT_USER\Software\"_
> > >      & "Microsoft\Windows\CurrentVersion\"_
> > >      & "Policies\Explorer\"
> > > sVal = "NoDriveTypeAutoRun"

> > > arBytes = shell.RegRead(sKey & sVal)

> > > for each byt in arBytes
> > >   s = s & right("0" & hex(byt),2) & " "
> > > next

> > > msgbox s

> > > --
> > > Michael Harris
> > > Microsoft MVP - Scripting

> > > "It always helps to read the documentation..."



> > > > Thanks for the explanation Michael,

> > > > I guess what I need to know is how to code a RegRead that will get
these
> > 4
> > > > bytes of data. I tried using an array and still get Type Mismatch.
> > Thanks
> > > > for any advice you can provide.

> > > > Kenny



> > > > > Looks like a 4 byte REG_BINARY value.

> > > > > When you RegRead any key or named value with a REG_BINARY value,
you
> > get
> > > > an array of variants of
> > > > > subtype byte with one element per byte.  This is for WSH 2.0 - WSH
1.0
> > > > gave you an array of bytes
> > > > > (not variants of subtype byte) that was much more difficult to
deal
> > > > with...

> > > > > --
> > > > > Michael Harris
> > > > > Microsoft MVP - Scripting


message

> > > > > > I am having some trouble trying to read certain values from the
> > Windows
> > > > 98
> > > > > > Registry. I have read the WSH documentation from MS and have
found
> > that
> > > > > > RegRead works only with certain data types. I keep getting Type
> > Mismatch
> > > > > > errors when I try to read the following value:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explore

- Show quoted text -

Quote:
> > > > > > r\NoDriveTypeAutoRun

> > > > > > The value shows up as 95 00 00 00 when using Regedit. There are
no
> > > > quotes
> > > > > > around the data, it is a numeric data type of some kind. I need
to
> > be
> > > > able
> > > > > > to read this information and change it if necessary.

> > > > > > I am assuming this is a limitation of WSH, but there has got to
be
> > > > another
> > > > > > way to get this information into/out of the registry using
> > scripting.

> > > > > > If anyone knows of a method to read and write this type of data
from
> > and
> > > > to
> > > > > > the registry using VBScript and/or WSH, your help would be
GREATLY
> > > > > > APPRECIATED!

> > > > > > TIA,

> > > > > > Kenny



Tue, 28 Jan 2003 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Registry KeyExist using RegRead() method

2. Problem of regread method.

3. RegRead method

4. RegRead Method with Binary Registry Keys

5. RegRead method on SharedDLLs

6. Scripting problem using Shell method to run ICQ

7. Problems using ADODB.Stream for Binarywrite method

8. BUG: Problem using the Restrict method in Office 2000 VBA code

9. problem using CopyFile method in remote script

10. Problem creating a Shortcut using the CreateShortcut Method

11. Problem using wsh.run method in 95 with really long command

12. Trouble using RegRead to see if RegKey exists

 

 
Powered by phpBB® Forum Software