Jump to content

Switch User


Recommended Posts

Not actually trying to "Switch User" so much as log out of current user (if logged in) and then log in our admin account before scripts are run, then logout of our admin once finished.

Any easier way to do this other than sending keys or mouse movements with pauses and such? I understand the logout part, but logging into a hidden (with registry) admin account seems to be near impossible being scripted in any way i can come up with.

Link to comment
Share on other sites

  • Moderators

Hi, RedneckTech. I would suggest, rather than a bunch of mouse movements, using the AutoAdminLogon feature. Basically you would enable AutoAdminLogon under HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon, enter the account you want to use with the DefaultUsernName and DefaultPassword values, then perform a reboot.

On reboot your machine will auto login with the credentials provided, and you can run your configuration scripts. Once it is done, you change the AutoAdminLogon back, and reboot again. Below is the path I use (2 scripts):

Script 1:

Configure DefaultUserName Value
Configure DefaultPassword Value
Change AutoAdminLogon to "1"
Create a value for Script 2 under HKLMSoftwareMicrosoftWindowsCurrentVersionRun to call the script on next reboot. <--Run, not RunOnce.
Reboot machine

Script 2:

Run whatever configuration duties you need.
Delete Value under HKLMSoftwareMicrosoftWindowsCurrentVersionRun
Set AutoAdminLogon value to "0"
(optional)
Set values in DefaultUserName and DefaultPassword to ""
Reboot

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

To make sure you can run the actions you need to run, enter your program in the run key ("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRun") by adding an entry named for example "DoJob" = "c:testDoJob.exe"

Then to reboot, there is the command "shutdown.exe /r", which you can run with ShellExecute

When your computer reboots using the default user and password set as jLogan explained above, it will read the Run key and run the DoJob.exe program. That programs will have to carry out several tasks:

1- remove the DoJob entry from the run key

2- do the things you want to do as the new user

3- if needed, enter the default user and password for the original user (again as explained by jLogan above), and reboot using Shutdown.exe /r

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...