×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Can you load a registry hive with VBS?

Can you load a registry hive with VBS?

Can you load a registry hive with VBS?

(OP)
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

RE: Can you load a registry hive with VBS?

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

RE: Can you load a registry hive with VBS?

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

RE: Can you load a registry hive with VBS?

(OP)
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.   

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close