RedneckTech Posted March 21, 2012 Posted March 21, 2012 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.
Moderators JLogan3o13 Posted March 21, 2012 Moderators Posted March 21, 2012 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!
rodent1 Posted March 21, 2012 Posted March 21, 2012 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now