maxwellsmart Posted February 3, 2004 Share Posted February 3, 2004 I have a script (to install a piece of software) which works fine while logged in as a user with Administrator priviledges. The same script doesn't work when that user has locked (not logged off) the PC. AutoIT acts as though it doesn't 'see' the initial setup window and the script pauses. Unlocking the PC doesn't cause the script to continue. Other scripts designed to install software have worked while the PC is locked. Any ideas as to why this is occuring? Thanks! Link to comment Share on other sites More sharing options...
Developers Jos Posted February 3, 2004 Developers Share Posted February 3, 2004 (edited) this is an example on how you can restart the script in Admin mode. You need to compile it first for it to work... AutoItSetOption ( "RunErrorsFatal", 0) AutoItSetOption ( "TrayIconHide", 1) ; variable definition $username="?????" ; local admin account name $Password="????????" ; local admin account psw $run = 0 ; run indicator 1=first cycle uninstall 2=install new ; retrieve commandline parameter If $CmdLine[0] = 1 then $run = $CmdLine[1] ; If $run = 0 then if isadmin() then Writelog("Already admin mode skipping to setp 2") $run = 1 else ; *** Changing credentials.. RunAsSet ($Username, @Computername, $Password) ; start the script program (itself) again but now in Adminmode...so all done tasks will run in Adminmode Run('"' & @ScriptFullPath & '" " 1"' ) ; if fails then exits because username & passsword is not correct if @error = 1 then msgbox(48,"Error","cannot start the installation because you are not in Admin mode ") exit endif exit endif EndIf ; do the stuff you need to do in admin mode Edited February 3, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
maxwellsmart Posted February 5, 2004 Author Share Posted February 5, 2004 Thanks for the response but the user is already a member of the Admin group. The script works when the user is logged in but doesn't when that same user locks the PC (I assume the user is still logged on but the PC is simply locked). Perhaps locking the PC disables keyboard input (except for Ctrl-Alt-Del for unlocking purposes) and therefore scripts cannot send keyboard commands successfully? Link to comment Share on other sites More sharing options...
nobby Posted February 6, 2004 Share Posted February 6, 2004 You are correct, keystrokes are limited to CTRL-ALT-DEL when locked, also if your script relies on sending mouse clicks to active windows it cannot work as a locked PC does not open windows "behind the scene". One way around the problem could be to: 1. Create a script that sets AutoAdminLogon, Username and Password and that puts an entry in the HKLM\soft\Mic\Win\CV\RunOnce as to execute the third script upon reboot and forces a reboot. 2. Create the script to install the software and include the removal of AutoAdminLogon and reboot. Script 1. RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon", "REG_SZ", "1") RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName", "REG_SZ", "USERNAME") RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword", "REG_SZ", "PASSWORD") RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultDomainName", "REG_SZ", "DOMAIN") RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce", "MYSCRIPT", "REG_SZ", "PATH\SCRIPTNAME") Shutdown(6) Don't forget to reset Autoadminlogon to "0" as part of the install script. Cheers CheersNobby Link to comment Share on other sites More sharing options...
maxwellsmart Posted February 7, 2004 Author Share Posted February 7, 2004 Turns out I can use the ControlSend function to have the script run successfully when the user is logged in but has locked the PC. 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