purpGUI Posted July 18, 2011 Share Posted July 18, 2011 Hi Forum, I am running into some issues with the RunAsWait command. Below is the relevant portion of my script: ; Include the installer with compiled script FileInstall("PATH\stuff.exe", @TempDir & "\stuff.exe") ... ... ; Must run installer with admin rights. Do not distribute ; codes. Compiled versions only. $username = "username" $domain = "domain" $password = "password" RunAsWait($username, $domain, $password, 0, @TempDir & "\stuff.exe") FileDelete(@TempDir & "\stuff.exe") If @error = 1 Then MsgBox("16","Error","Something went wrong during installation. Exiting.") Exit The username/domain/password fields are filled with my credentials. I have admin rights and the script works properly IF I launch the script as admin, but fails miserably otherwise. The helpfile for RunAsWait mentions that Secondary Logon must be running, and it is. Help appreciated. Link to comment Share on other sites More sharing options...
tlman12 Posted July 18, 2011 Share Posted July 18, 2011 Hi Forum, I am running into some issues with the RunAsWait command. Below is the relevant portion of my script: ; Include the installer with compiled script FileInstall("PATH\stuff.exe", @TempDir & "\stuff.exe") ... ... ; Must run installer with admin rights. Do not distribute ; codes. Compiled versions only. $username = "username" $domain = "domain" $password = "password" RunAsWait($username, $domain, $password, 0, @TempDir & "\stuff.exe") FileDelete(@TempDir & "\stuff.exe") If @error = 1 Then MsgBox("16","Error","Something went wrong during installation. Exiting.") Exit The username/domain/password fields are filled with my credentials. I have admin rights and the script works properly IF I launch the script as admin, but fails miserably otherwise. The helpfile for RunAsWait mentions that Secondary Logon must be running, and it is. Help appreciated. just a guess here but what may be happening is the @TempDir macro is changing. I had a similar issue once I got around it by saying $TempDir = @TempDir at the beginning of the script and calling the path with $TempDir instead of @TempDir what happens is if you start the script as "UserA" then @TempDir = "C:\Users\UserA\AppData\Local\Temp" but then when you RunAsWait "UserB" the @TempDir macro would be "C:\Users\UserB\AppData\Local\Temp" and the file would not exist. $TempDir = @TempDir ; Include the installer with compiled script FileInstall("PATH\stuff.exe", $TempDir & "\stuff.exe") ... ... ; Must run installer with admin rights. Do not distribute ; codes. Compiled versions only. $username = "username" $domain = "domain" $password = "password" RunAsWait($username, $domain, $password, 0, $TempDir & "\stuff.exe") FileDelete($TempDir & "\stuff.exe") If @error = 1 Then MsgBox("16","Error","Something went wrong during installation. Exiting.") Exit Link to comment Share on other sites More sharing options...
purpGUI Posted July 18, 2011 Author Share Posted July 18, 2011 (edited) just a guess here but what may be happening is the @TempDir macro is changing. I had a similar issue once I got around it by saying $TempDir = @TempDir at the beginning of the script and calling the path with $TempDir instead of @TempDir what happens is if you start the script as "UserA" then @TempDir = "C:\Users\UserA\AppData\Local\Temp" but then when you RunAsWait "UserB" the @TempDir macro would be "C:\Users\UserB\AppData\Local\Temp" and the file would not exist. $TempDir = @TempDir ; Include the installer with compiled script FileInstall("PATH\stuff.exe", $TempDir & "\stuff.exe") ... ... ; Must run installer with admin rights. Do not distribute ; codes. Compiled versions only. $username = "username" $domain = "domain" $password = "password" RunAsWait($username, $domain, $password, 0, $TempDir & "\stuff.exe") FileDelete($TempDir & "\stuff.exe") If @error = 1 Then MsgBox("16","Error","Something went wrong during installation. Exiting.") Exit Hi tlman, Thanks for your reply. Is @TempDir evaluated at compile time or run-time? If it's evaluated at compile-time, I can see where @TempDir would be different. However, if it's evaluated at run-time, shouldn't @TempDir be consistent in the lifetime of the script? I might be mentally challenged. Nevertheless, I did try your method of having a constant path. Alas, it's still refusing to work Will keep trying. Thanks! EDIT: Just saw that you pointed out @TempDir is a macro. New to AutoIt so didn't realize the @xxx names are all macros. That would make sense. I've changed the code to ensure a constant path. EDIT2: Edited July 18, 2011 by purpGUI Link to comment Share on other sites More sharing options...
tlman12 Posted July 18, 2011 Share Posted July 18, 2011 Hi tlman,Thanks for your reply. Is @TempDir evaluated at compile time or run-time? If it's evaluated at compile-time, I can see where @TempDir would be different. However, if it's evaluated at run-time, shouldn't @TempDir be consistent in the lifetime of the script?Nevertheless, I did try your method of having a constant path. Alas, it's still refusing to work Will keep trying.Thanks!@TempDir is evaluated at runtime but all it is is the environment variable %temp% so anytime the user credentials change the %temp% would change. can you put a variable in front of runaswait like $iReturn = RunAsWait(" and see what $iReturn becomes after a failure? Link to comment Share on other sites More sharing options...
purpGUI Posted July 18, 2011 Author Share Posted July 18, 2011 RunAsWait returns 0 with nonzero @error. 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