Hi,

I want to know how can I use VBscript to create a folder in the registry?

Thanks in advance

Re: Registry handling by Torgeir

Torgeir
Thu Jun 23 07:08:31 CDT 2005

ed wrote:

> I want to know how can I use VBscript to create a folder in
> the registry?
Hi,

With WScript.Shell's RegWrite

'--------------------8<----------------------
Set oShell = CreateObject("WScript.Shell")

' new key path to be created
sKeyPath = "HKLM\SOFTWARE\MyKey"

oShell.RegWrite sKeyPath & "\dummy", ""
oShell.RegDelete sKeyPath & "\dummy"
'--------------------8<----------------------


With WMI's StdRegProv class:

'--------------------8<----------------------
Const HKLM = &H80000002
sComputer = "."

Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& sComputer & "\root\default:StdRegProv")

' new key path to be created
sKeyPath = "SOFTWARE\MyKey"
oReg.CreateKey HKLM, sKeyPath
'--------------------8<----------------------



--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: Registry handling by RogueIT

RogueIT
Thu Jun 23 09:05:02 CDT 2005

How would you specify REG_SZ & REG_DWORD's and how would you name their values?
For example say I wanted a dword value named custid and a hex value of 270b
and
a reg_sz value named database with a value of dsql
how would I specify that?

thanks
rogueIT

"Torgeir Bakken (MVP)" wrote:

> ed wrote:
>
> > I want to know how can I use VBscript to create a folder in
> > the registry?
> Hi,
>
> With WScript.Shell's RegWrite
>
> '--------------------8<----------------------
> Set oShell = CreateObject("WScript.Shell")
>
> ' new key path to be created
> sKeyPath = "HKLM\SOFTWARE\MyKey"
>
> oShell.RegWrite sKeyPath & "\dummy", ""
> oShell.RegDelete sKeyPath & "\dummy"
> '--------------------8<----------------------
>
>
> With WMI's StdRegProv class:
>
> '--------------------8<----------------------
> Const HKLM = &H80000002
> sComputer = "."
>
> Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
> & sComputer & "\root\default:StdRegProv")
>
> ' new key path to be created
> sKeyPath = "SOFTWARE\MyKey"
> oReg.CreateKey HKLM, sKeyPath
> '--------------------8<----------------------
>
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>

Re: Registry handling by Torgeir

Torgeir
Thu Jun 23 09:24:38 CDT 2005

RogueIT wrote:

> How would you specify REG_SZ & REG_DWORD's and how would you name their values?
> For example say I wanted a dword value named custid and a hex value of 270b
> and
> a reg_sz value named database with a value of dsql
> how would I specify that?
Hi,


'--------------------8<----------------------
Set oShell = CreateObject("WScript.Shell")

sKeyPath = "HKLM\SOFTWARE\MyKey"

oShell.RegWrite sKeyPath & "\custid", "&H270b", "REG_DWORD"
oShell.RegWrite sKeyPath & "\database", "dsql", "REG_SZ"
'--------------------8<----------------------


WSH 5.6 documentation (local help file) can be downloaded
from here if you haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: Registry handling by RogueIT

RogueIT
Thu Jun 23 09:45:12 CDT 2005

Dude...you totally Rock...thanks

"Torgeir Bakken (MVP)" wrote:

> RogueIT wrote:
>
> > How would you specify REG_SZ & REG_DWORD's and how would you name their values?
> > For example say I wanted a dword value named custid and a hex value of 270b
> > and
> > a reg_sz value named database with a value of dsql
> > how would I specify that?
> Hi,
>
>
> '--------------------8<----------------------
> Set oShell = CreateObject("WScript.Shell")
>
> sKeyPath = "HKLM\SOFTWARE\MyKey"
>
> oShell.RegWrite sKeyPath & "\custid", "&H270b", "REG_DWORD"
> oShell.RegWrite sKeyPath & "\database", "dsql", "REG_SZ"
> '--------------------8<----------------------
>
>
> WSH 5.6 documentation (local help file) can be downloaded
> from here if you haven't got it already:
> http://msdn.microsoft.com/downloads/list/webdev.asp
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>

Re: Registry handling by RogueIT

RogueIT
Thu Jun 23 10:01:05 CDT 2005

OK. I have an input box come up and ask for customer number
Set oShell = CreateObject("WScript.Shell")
Dim Input
Input = InputBox("Enter Customer Number")
Inputpassword = InputBox("Enter Customer Password")
Inputstore = Inputbox("Enter Store Name")
sKeyPath = "HKLM\SOFTWARE\DOHMEN\SettingsDPOS\" & input

oShell.RegWrite sKeyPath & "\custid", "&H270b", "REG_DWORD"
How would I take user input and convert to hex for the dword value?

thanks in advance

"Torgeir Bakken (MVP)" wrote:

> RogueIT wrote:
>
> > How would you specify REG_SZ & REG_DWORD's and how would you name their values?
> > For example say I wanted a dword value named custid and a hex value of 270b
> > and
> > a reg_sz value named database with a value of dsql
> > how would I specify that?
> Hi,
>
>
> '--------------------8<----------------------
> Set oShell = CreateObject("WScript.Shell")
>
> sKeyPath = "HKLM\SOFTWARE\MyKey"
>
> oShell.RegWrite sKeyPath & "\custid", "&H270b", "REG_DWORD"
> oShell.RegWrite sKeyPath & "\database", "dsql", "REG_SZ"
> '--------------------8<----------------------
>
>
> WSH 5.6 documentation (local help file) can be downloaded
> from here if you haven't got it already:
> http://msdn.microsoft.com/downloads/list/webdev.asp
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>

Re: Registry handling by Torgeir

Torgeir
Thu Jun 23 10:21:45 CDT 2005

RogueIT wrote:

> OK. I have an input box come up and ask for customer number
> Set oShell = CreateObject("WScript.Shell")
> Dim Input
> Input = InputBox("Enter Customer Number")
> Inputpassword = InputBox("Enter Customer Password")
> Inputstore = Inputbox("Enter Store Name")
> sKeyPath = "HKLM\SOFTWARE\DOHMEN\SettingsDPOS\" & input
>
> oShell.RegWrite sKeyPath & "\custid", "&H270b", "REG_DWORD"
> How would I take user input and convert to hex for the dword value?
>
> thanks in advance
Hi,

Is the "Customer Number" in the variable input supposed to be both a
registry key, as well as the value data in the registry value custid?

If it is supposed to be a key as well (the "...SettingsDPOS\" & input"
part), is that key name represented as a hex value?


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: Registry handling by RogueIT

RogueIT
Thu Jun 23 11:01:03 CDT 2005

I think I understand what you are asking and YES

Set oShell = CreateObject("WScript.Shell")
Dim Input
Input = InputBox("Enter Customer Number")
sKeyPath = "HKLM\SOFTWARE\DOHMEN\SettingsDPOS\" & input

oShell.RegWrite sKeyPath & "\custid", "&H270b", "REG_DWORD"
oShell.RegWrite sKeyPath & "\globaluid", input & "WDDA", "REG_SZ"
oShell.RegWrite sKeyPath & "\custname", input , "REG_SZ"
will crate the following registry entrys
[HKEY_LOCAL_MACHINE\SOFTWARE\DOHMEN\SettingsDPOS\9995]
"custid"=dword:0000270b
"globaluid"="9995WDDA"
"custname"="9995"
But I want to change "&H270B" TO "&H" & INPUT


"Torgeir Bakken (MVP)" wrote:

> RogueIT wrote:
>
> > OK. I have an input box come up and ask for customer number
> > Set oShell = CreateObject("WScript.Shell")
> > Dim Input
> > Input = InputBox("Enter Customer Number")
> > Inputpassword = InputBox("Enter Customer Password")
> > Inputstore = Inputbox("Enter Store Name")
> > sKeyPath = "HKLM\SOFTWARE\DOHMEN\SettingsDPOS\" & input
> >
> > oShell.RegWrite sKeyPath & "\custid", "&H270b", "REG_DWORD"
> > How would I take user input and convert to hex for the dword value?
> >
> > thanks in advance
> Hi,
>
> Is the "Customer Number" in the variable input supposed to be both a
> registry key, as well as the value data in the registry value custid?
>
> If it is supposed to be a key as well (the "...SettingsDPOS\" & input"
> part), is that key name represented as a hex value?
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>

Re: Registry handling by Torgeir

Torgeir
Thu Jun 23 11:52:45 CDT 2005

RogueIT wrote:

> I think I understand what you are asking and YES
>
> Set oShell = CreateObject("WScript.Shell")
> Dim Input
> Input = InputBox("Enter Customer Number")
> sKeyPath = "HKLM\SOFTWARE\DOHMEN\SettingsDPOS\" & input
>
> oShell.RegWrite sKeyPath & "\custid", "&H270b", "REG_DWORD"
> oShell.RegWrite sKeyPath & "\globaluid", input & "WDDA", "REG_SZ"
> oShell.RegWrite sKeyPath & "\custname", input , "REG_SZ"
> will crate the following registry entrys
> [HKEY_LOCAL_MACHINE\SOFTWARE\DOHMEN\SettingsDPOS\9995]
> "custid"=dword:0000270b
> "globaluid"="9995WDDA"
> "custname"="9995"
> But I want to change "&H270B" TO "&H" & INPUT
Hi,

There is no need to do that with WSH's RegWrite for REG_DWORD values,
you can just write the decimal value to registry, it will end up
correct anyway.

So this should work fine:

oShell.RegWrite sKeyPath & "\custid", input, "REG_DWORD"


If you in another setting really need to convert from decimal to hex,
use the Hex function:

WScript.Echo Hex(9995)


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: Registry handling by RogueIT

RogueIT
Thu Jun 23 14:11:02 CDT 2005

well that will do it...just a couple of other questions but I think I will be
able to take care of them with a search...if not be sure I will post.
thanks for your help