Jump to content

load .reg file into currently logged-in user


 Share

Recommended Posts

Hello Guys,

I need to deploy a script to change printer settings to default values (like default monochrome and duplex printing). The script runs fine when executed on the local machine. But when I use our deployment console to remotely run the script on the end-users workstation, the .reg settings do not take effect on the logged-in user.

I suspect that the script loads the .reg settings into the administrator account and not on the currently logged-in user.

I have been seeing the @username function but don't know how to implement it to load a .reg file. I'm sure experts here can code this in less than 5minutes :)

pls help. thanks...

Link to comment
Share on other sites

Can't remeber the switch so take a look

regsrv32.exe /?
Lets say it was /s
;Could be runwait is better
ShellExecute("regsrv32.exe /s " & $pathtoregfile)

Obviously I know nothing about the content in your reg file so it could be your problem lies there.

If your running as a user (restricted) this should not go to the administrator account.

Link to comment
Share on other sites

the script im running runs under the administrator account while a standard user is logged-in. but i want the script to have a effect on the currently logged-in user.

is it possible that when the regedit /s executes, it will run in the context of the logged-in user?

Link to comment
Share on other sites

You could use RunAsSet But, I think, that would give you a headache if you don't have all the passwords.

But I'm sure there is a way to do it. But unfortunately I don't know howto either. Maybe someone else could give some clues?

EDIT: Wrong link type.

Edited by Uten
Link to comment
Share on other sites

the script im running runs under the administrator account while a standard user is logged-in. but i want the script to have a effect on the currently logged-in user.

is it possible that when the regedit /s executes, it will run in the context of the logged-in user?

what you need is reg.exe.

You can write to a users hive (HKCU) by loading that hive to your current registry, modifying it, then unloading the hive.

reg.exe LOAD HKLM\userhive "c:\documents and settings\user1234\ntuser.dat"

reg.exe ADD HKLM\userhive\testkey ; HERE you can also use AU3 Reg* functions!

reg.exe UNLOAD HKLM\userhive

Help: reg /?

This will only work, if the hive file (ntuser.dat) is NOT locked, e.g. because the user is logged on!!!

WARNING: Be careful using reg.exe, as you can really f... up your registry!!

EDIT: BTW, you could also write to HKEY_USERS\S-1-5-xxxxxxxxxx, but then you'll have to figure out the SID of the user you want to change.

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...