butterfly888 Posted June 23, 2010 Share Posted June 23, 2010 Real newbie here... Can someone tell me how to create a script that logs off the current user on WinXP and then enters the username/password for a different user to login windows. I saw Shutdown in Help topics but what do I use with Shutdown to login the new user? Thanks. Link to comment Share on other sites More sharing options...
HalH Posted June 24, 2010 Share Posted June 24, 2010 logs off the current user on WinXP This will get you logged off: shutdown -l But this: enters the username/password for a different user to login windows is an entirely different ball of wax. I don't know if that even can be done as the program launched under one user who logs will likely be killed in the logoff. Link to comment Share on other sites More sharing options...
sunzen Posted June 24, 2010 Share Posted June 24, 2010 is an entirely different ball of wax. I don't know if that even can be done as the program launched under one user who logs will likely be killed in the logoff.I also have the interesting of logoning windows system automatically with tools like AutoIT. Is is really impossible? Is there anyone who have something to say about this topic? ThanksSunzen Link to comment Share on other sites More sharing options...
Juvigy Posted June 24, 2010 Share Posted June 24, 2010 You can set the PC to auto login with predefined credentials. It will not ask for user name and password and just log in. Link to comment Share on other sites More sharing options...
Anteaus Posted June 24, 2010 Share Posted June 24, 2010 (edited) Basically, the logon window runs under a separate desktop, and is heavily protected against sending of keystrokes to it. Hence this approach is extremely difficult. The simplest workaround is to use autologon, which involves creating some registry values in the Winlogon key, $Winlogon="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" RegWrite($Winlogon,"DefaultPassword","REG_SZ","noneofyourbusiness") RegWrite($Winlogon,"DefaultUserName","REG_SZ","myname") RegWrite($Winlogon,"AutoAdminLogon","REG_SZ","1") RegWrite($Winlogon,"ForceAutoLogon","REG_SZ","1") $tmp=RegRead($Winlogon,"DefaultDomainName") if @error then RegWrite($Winlogon,"DefaultDomainName","REG_SZ",@computername) When set correctly a shutdown command will result in an immediate re-logon with the credentials given. To prevent this, hold shift whilst issuing shutdown. Slight disadvantage is that anyone who knows how to use regedit can find the password, as it has to be plaintext. http://support.microsoft.com/?kbid=315231 Other approach would be to use 'control userpasswords2' and Send() the keystrokes required to it. You still need to set ForceAutoLogon directly though. Edited June 24, 2010 by Anteaus Link to comment Share on other sites More sharing options...
butterfly888 Posted June 24, 2010 Author Share Posted June 24, 2010 This will get you logged off: shutdown -l But this: is an entirely different ball of wax. I don't know if that even can be done as the program launched under one user who logs will likely be killed in the logoff. Yeah, I was thinking the same thing that the script would be killed. Ok, thanks for your input. Link to comment Share on other sites More sharing options...
Bert Posted June 24, 2010 Share Posted June 24, 2010 Is this to install software? You could do a RunAs to install the application. The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
butterfly888 Posted June 24, 2010 Author Share Posted June 24, 2010 Basically, the logon window runs under a separate desktop, and is heavily protected against sending of keystrokes to it. Hence this approach is extremely difficult. The simplest workaround is to use autologon, which involves creating some registry values in the Winlogon key, $Winlogon="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" RegWrite($Winlogon,"DefaultPassword","REG_SZ","noneofyourbusiness") RegWrite($Winlogon,"DefaultUserName","REG_SZ","myname") RegWrite($Winlogon,"AutoAdminLogon","REG_SZ","1") RegWrite($Winlogon,"ForceAutoLogon","REG_SZ","1") $tmp=RegRead($Winlogon,"DefaultDomainName") if @error then RegWrite($Winlogon,"DefaultDomainName","REG_SZ",@computername) When set correctly a shutdown command will result in an immediate re-logon with the credentials given. To prevent this, hold shift whilst issuing shutdown. Slight disadvantage is that anyone who knows how to use regedit can find the password, as it has to be plaintext. http://support.microsoft.com/?kbid=315231 Other approach would be to use 'control userpasswords2' and Send() the keystrokes required to it. You still need to set ForceAutoLogon directly though. Yes setting registry values for Winlogon should work for what I'm doing. Since the password displays in plaintext I could remove the value for DefaultPassword after my script runs. Now the does the user who launches the script need to be a local administrator since values are been set in the registry? What is this check for? $tmp=RegRead($Winlogon,"DefaultDomainName") if @error then RegWrite($Winlogon,"DefaultDomainName","REG_SZ",@computername) Thanks for our help. Link to comment Share on other sites More sharing options...
Bert Posted June 24, 2010 Share Posted June 24, 2010 The user doesn't need to be a local administrator. Using RunAs allows you to simply use the administrator account to do what you want to do. To setup the auto logon, I do believe you have to do the RunAs. The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
butterfly888 Posted June 24, 2010 Author Share Posted June 24, 2010 Is this to install software? You could do a RunAs to install the application.No I'm not installing software. I'm running a mult-user application. So user1 launches the script. My script would launch the application, do some things, close the application, logoff user1, then login as user2 to launch the application and do some things. Would RunAs work in this scenario? Link to comment Share on other sites More sharing options...
Anteaus Posted June 24, 2010 Share Posted June 24, 2010 (edited) Now the does the user who launches the script need to be a local administrator since values are been set in the registry?$tmp=RegRead($Winlogon,"DefaultDomainName")if @error then RegWrite($Winlogon,"DefaultDomainName","REG_SZ",@computername)Yes, to set the values, but not to autologon once set.The check is in case the domain isn't set. (if the computer is an AD member we don't want to disturb any existing value)RunAs will work in most cases if you just need to test an app under different credentials. Edited June 24, 2010 by Anteaus Link to comment Share on other sites More sharing options...
butterfly888 Posted June 24, 2010 Author Share Posted June 24, 2010 Yes, to set the values, but not to autologon once set.The check is in case the domain isn't set. (if the computer is an AD member we don't want to disturb any existing value)RunAs will work in most cases if you just need to test an app under different credentials.Ok cool. Thanks again for you help and speedy responses. Link to comment Share on other sites More sharing options...
Mat Posted June 24, 2010 Share Posted June 24, 2010 This is a UDF several people + me worked on a while back to do exactly this: http://www.autoitscript.com/forum/index.php?showtopic=94609 AutoIt Project Listing Link to comment Share on other sites More sharing options...
butterfly888 Posted June 24, 2010 Author Share Posted June 24, 2010 This is a UDF several people + me worked on a while back to do exactly this:http://www.autoitscript.com/forum/index.php?showtopic=94609Ok cool, I'll check it out. Thank you. Link to comment Share on other sites More sharing options...
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