Reply To: set default printer – script

#12724
Joe
Member
  • Total Post: 104
  • Legend in Own LunchBox
  • ★★★★★

This may or may not help you, but here is some code that I use to get entries in to the user registry instead of the system users registry.

This is going to go at the beginning of your vbscript. It will actually load the users registry hive and allow you to modify it.


Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run("Reg Load HKUChangeMe " & chr(34) & "C:Documents and SettingsUserNTUser.dat" & chr(34))
wscript.echo "Sleeping..."
wscript.sleep 2000

Once this is done, you can access the registry by using HKEY_USERSChangeMe instead of HKEY_CURRENT_USER.

When you are done, you will need to unload the hive using the following code:


objShell.Run("Reg Unload HKUChangeMe")
wscript.echo "Sleeping..."
wscript.sleep 2000

Now, I’m still looking into this, but I have a hunch that it might not work if the script executes while the user is logged in, but I’m having some other problems and can’t confirm that right now. I figured I would just throw it out there just in case it might help you!