PDA

View Full Version : Create a folder in Registry w/VBS (W2K)



configur3d
03-24-2003, 09:55 AM
I have a .reg file which i'm trying to mimic with a vbscript. The script creates a folder within the HKLM\software\ and then sub folders. How do I do that. I'm an ultranewbie to Vbscripting but i need this for work.

Mosaic1
03-24-2003, 03:01 PM
To help we need more information. What kind of values and their data etc to build a key. Exporting the key and letting someone have a look at it would be a better way to go.

Here's a vbscript which builds a bare bones Key with three Subkeys under:
HKEY_CLASSES_ROOT\*

These keys have only the "default" String Value and the data is (value not set)


Dim WSHShell
Set WSHShell=Wscript.CreateObject("Wscript.Shell")
WSHShell.RegWrite "HKCR\*\Winguides\Forums\" ,"(value not set)","REG_SZ"
WSHShell.RegWrite "HKCR\*\Winguides\Scripting\" ,"(value not set)","REG_SZ"
WSHShell.RegWrite "HKCR\*\Winguides\Tweaks\" ,"(value not set)","REG_SZ"


The First key is Winguides.
Under Winguides are three Subkeys.
The three subkeys are:
Forums
Scripting
Tweaks


Here's how it looks when exported:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\Winguides]

[HKEY_CLASSES_ROOT\*\Winguides\Forums]
@="(value not set)"

[HKEY_CLASSES_ROOT\*\Winguides\Scripting]
@="(value not set)"

[HKEY_CLASSES_ROOT\*\Winguides\Tweaks]
@="(value not set)"



I used value not set, you can also leave that data empty. It's your choice how you would like to do it. Just use "" where I typed "(value not set)"

Mosaic1
03-24-2003, 03:28 PM
May I make an alternate suggestion? Export the Key you want to mimic to create a reg file. Write a batch file to import the registry file as a Startup or Login script on the computer(s) in question.

configur3d
03-25-2003, 08:33 AM
Hey, thanks for the input. played with it and viola. Nice. but it would be easier to just to use the .reg file i already have. How do I import the .reg file with a batch file? I think this might be the way to go. Thanks for all your help.

Mosaic1
03-25-2003, 10:04 AM
Here's a command to import a registry file named fix.reg from C:\WinNt and avoid the confirmation boxes. You said Win2k? See if this command gives you the right path. Substitute the path to the registry file you want to import.

regedit /s "%systemroot%\fix.reg"

In XP there is another command.

reg import

It always imports a file silently.

Here's that command. I am not familiar with 2k, but you probably have this one.

reg import "%systemroot%\fix.reg"

Paste a command into Notepad and save the file as
whatever.bat

configur3d
03-28-2003, 06:44 AM
Hey it worked awesome. You all dat and a family sized bag-o-chips