Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you load a registry hive with VBS?

Status
Not open for further replies.

twoody54

IS-IT--Management
Apr 11, 2002
150
US
I'm trying to load the default user registry hive and import some settings into it.

Right now, I manually load the hive and then run my reg file to import the settings. Is there a way I can do this through VBS script?

Logically the VBS script would
LOAD HIVE
run the regedit file (regedit /s myregfile.reg)
UNLOAD the hive.


Thanks for your time
 
Have you taken a look at the REG app

C:\>reg /?

Registry Console Tool For Windows 2000 - version 2.0
Copyright (C) Microsoft Corp. 1981-1999. All rights reserved

REG Operation [Parameter List]

Operation [ QUERY | ADD | DELETE | COPY |
SAVE | LOAD | UNLOAD | RESTORE |
COMPARE | EXPORT | IMPORT ]

Return Code: (Except of REG COMPARE)

0 - Succussful
1 - Failed

For help on a specific operation type:

REG Operation /?

Examples:

REG QUERY /?
REG ADD /?
REG DELETE /?
REG COPY /?
REG SAVE /?
REG RESTORE /?
REG LOAD /?
REG UNLOAD /?
REG COMPARE /?
REG EXPORT /?
REG IMPORT /?


dm4ever
--------------------------------------------------------------------------------
My approach to things: K.I.S.S - Keep It Simple Stupid
 
I found this example is a google search.

Function ModUserHive()
'Loads, Changes and Unloads Default User Hive to change preferred walpaper and background color
set objshell = CreateObject("Wscript.shell")
strComputer = "."
strKeyPath1 = "Tempdefault\Control Panel\Desktop"
strKeyPath2 = "Tempdefault\Control Panel\Colors"
objshell.Exec ("%comspec% /k reg.exe load HKU\Tempdefault c:\Docume~1\Defaul~1\ntuser.dat")
Set objReg = GetObject("winmgmts:" & _
"{impersonationLevel=Impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

objReg.SetStringValue HKEY_USERS,strKeyPath1,"Wallpaper","C:\WINDOWS\Web\Wallpaper\kiosk.bmp"
objReg.SetStringValue HKEY_USERS,strKeyPath1,"OriginalWallpaper","C:\WINDOWS\Web\Wallpaper\kiosk.bmp"
objReg.SetStringValue HKEY_USERS,strKeyPath2,"Background","26 98 4"

'objshell.Exec ("%comspec% /k reg.exe unload HKU\Tempdefault")
End Function

dm4ever
--------------------------------------------------------------------------------
My approach to things: K.I.S.S - Keep It Simple Stupid
 
Thanks guys. I've already used reg.exe to accomplish what I need. I was just hoping there was a way to do it with VBS script. The VBS script posted uses the reg command as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top