elyos002 Posted May 6, 2010 Share Posted May 6, 2010 Hi, I am new on the forum and I am french. I just begin to use autoit that is why I would like to have some help.In fact, I try to make an automatic uninstallation of a software version and then an automatic install of the new version.When the script works on the administator session, its works very well. This script is below :; Script Start - Add your code below hereMsgBox(48, "AV5", "uninstallation is beginning. Please do not touch to your keyboard!")Run ( "C:\Program Files\AT\unins000.exe" ) sleep ( 2000 ) send ( "!O" ) sleep ( 2000 )send ( "{ENTER}" )sleep ( 5000 )send ( "{ENTER}" ) sleep ( 5000 )DirRemove( "C:\Program Files\AT", 1)MsgBox(48, "AV7", "deinstall is beginning. Please do not touch to your keyboard")Run ( "C:\AV7.exe" ) WinWaitActive ( "Langue de l'assistant d'installation" )sleep ( 3000 ) send ( "{ENTER}" ) sleep ( 3000 )send ( "{ENTER}" ) sleep ( 3000 )send ( "!A" ) sleep ( 3000 )send ( "{ENTER}" ) sleep ( 3000 )send ( "!S" ) sleep ( 3000 )send ( "!S" ) sleep ( 3000 )send ( "!O" ) sleep ( 2000 )send ( "{TAB}" ) sleep ( 2000 )send ( "{DOWN}" ) sleep ( 500 )send ( "{DOWN}" ) sleep ( 500 )send ( "{DOWN}" ) sleep ( 500 )send ( "{DOWN}" ) sleep ( 500 )send ( "{DOWN}" ) sleep ( 500 )send ( "{DOWN}" ) sleep ( 500 )send ( "{DOWN}" ) sleep ( 500 ) ;send ( "{DOWN}" ) sleep ( 500 )send ( "{SPACE}" ) sleep ( 5000 )send ( "!S" ) sleep ( 3000 )send ( "!S" ) sleep ( 3000 )send ( "!S" ) sleep ( 3000 )send ( "!I" ) sleep ( 20000 )send ( "!T" ) Exit But when I try to run the script on a user session, it does not run well. After removal of the former version, it install the new one, but in the same time another occurence of the script runs. The only difference with the script made for the administrator session is a loop which determnine if the current user is administrator or not. And if he is not, which makes a "runas" command.; Script Start - Add your code below here$user = "Administrator"$pass = "xxxxxxxx"If Not IsAdmin() Then RunAs($user, @ComputerName, $pass, 0, @ScriptName, @ScriptDir) ExitEndIfMsgBox(48, "AV5", "uninstallation is beginning. Please do not touch to your keyboard!")Run ( "C:\Program Files\AT\unins000.exe" ) sleep ( 2000 ) send ( "!O" ) sleep ( 2000 )send ( "{ENTER}" )sleep ( 5000 )send ( "{ENTER}" ) sleep ( 5000 )DirRemove( "C:\Program Files\AT", 1)MsgBox(48, "AV7", "deinstall is beginning. Please do not touch to your keyboard")Run ( "C:\AV7.exe" ) WinWaitActive ( "Langue de l'assistant d'installation" )sleep ( 3000 ) send ( "{ENTER}" ) sleep ( 3000 )send ( "{ENTER}" ) sleep ( 3000 )send ( "!A" ) sleep ( 3000 )send ( "{ENTER}" ) sleep ( 3000 )send ( "!S" ) sleep ( 3000 )send ( "!S" ) sleep ( 3000 )send ( "!O" ) sleep ( 2000 )send ( "{TAB}" ) sleep ( 2000 )send ( "{DOWN}" ) sleep ( 500 )send ( "{DOWN}" ) sleep ( 500 )send ( "{DOWN}" ) sleep ( 500 )send ( "{DOWN}" ) sleep ( 500 )send ( "{DOWN}" ) sleep ( 500 )send ( "{DOWN}" ) sleep ( 500 )send ( "{DOWN}" ) sleep ( 500 ) ;send ( "{DOWN}" ) sleep ( 500 )send ( "{SPACE}" ) sleep ( 5000 )send ( "!S" ) sleep ( 3000 )send ( "!S" ) sleep ( 3000 )send ( "!S" ) sleep ( 3000 )send ( "!I" ) sleep ( 20000 )send ( "!T" ) Exit What did I make wrong in this second script?Thank you for your answers. Link to comment Share on other sites More sharing options...
SKlocke Posted May 6, 2010 Share Posted May 6, 2010 For your script, I think you should use the RunAsWait to run the script as admin. This will pause your first instance while the second is running. RunAs will continue execution of the first instance without waiting. Also, you could have a look at the #RequireAdmin keyword, which will perform a similar function. 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