BrandonW Posted June 2, 2009 Share Posted June 2, 2009 I was turned onto Autoit by our SysAdmin and have never been much into programming, but this seems to not be extremely complicated. Here is what I am trying to do: Normally, we have a folder on our storage server that we copy over to the local drive. In that folder, we run a batch file that installs our software then closes. I run a autologon reghack, then reboot the computer. What I want is to double-click on *.exe that creates a folder on the desktop, copies the contents of the install folder from the server to the local folder. Then, execute the batch file and when it is done, show a message basically saying "Done" and then reboot automatically after 30 seconds or so. I'm not worried about running the reghack right now. The script below is what I have with shutdown disabled for now. It will execute the batch file, but close it after a couple seconds and give the Done message. This batch file takes anywhere from 10-20 seconds depending on the PC specs. What am I missing/doing wrong here? ; Prompt the user to run the script $answer = MsgBox(4, "QS Install Process", "This script will copy the QS folder to the desktop and run install.cmd. Run?") ; Check the user's answer to the prompt ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(0, "AutoIt", "OK. Bye!") Exit EndIf ; Creates a directory on the local desktop called QS Install DirCreate("C:\Documents and Settings\user\Desktop\QS Install") ; Copies the contents of the qs install folder on server to the QS Install folder DirCopy("\\server\install\qs install folder", "C:\Documents and Settings\user\Desktop\QS Install", 1) ; Runs Install.bat and waits to finish before continuing script Run("C:\Documents and Settings\user\Desktop\QS Install\Install.bat") WinWaitClose("C:\WINDOWS\system32\cmd.exe") ; Script completed. Wait 30 seconds then force reboot MsgBox(4096, "Done", "Test 12", 30) ;Shutdown(6);Reboot Link to comment Share on other sites More sharing options...
Inverted Posted June 2, 2009 Share Posted June 2, 2009 (edited) First, use the RunWait function to replace run and winwaitclose. Edited June 2, 2009 by Inverted Link to comment Share on other sites More sharing options...
Developers Jos Posted June 2, 2009 Developers Share Posted June 2, 2009 RunWait() in stead of Run() ? 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...
BrandonW Posted June 2, 2009 Author Share Posted June 2, 2009 I tried RunWait and it did the same thing. I read somewhere on here that it could be some issue with the command prompt. Link to comment Share on other sites More sharing options...
Developers Jos Posted June 2, 2009 Developers Share Posted June 2, 2009 Does that mean that the Batchfile is done before the program shelled by the batch file finishes? You could try to use the COmspec to shell the batch file, but else we need more info what the batchfile is doing. RunWait(@comspec ' /c "C:\Documents and Settings\user\Desktop\QS Install\Install.bat"') 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...
BrandonW Posted June 2, 2009 Author Share Posted June 2, 2009 The batch file is executing a couple reghacks, settings attributes on ntuser.dat, then copying a couple folders from another server, then executing an msi quietly. It doesn't even get to the MSI. Link to comment Share on other sites More sharing options...
Inverted Posted June 2, 2009 Share Posted June 2, 2009 (edited) Are you sure the batch itself works properly (when launched from that location ?) Insert some pauses in the batch to debug the problem Edited June 2, 2009 by Inverted Link to comment Share on other sites More sharing options...
BrandonW Posted June 2, 2009 Author Share Posted June 2, 2009 Without a doubt. I ran it from the newly created folder and it works like a charm. Link to comment Share on other sites More sharing options...
BrandonW Posted June 2, 2009 Author Share Posted June 2, 2009 (edited) Are you sure the batch itself works properly (when launched from that location ?)Insert some pauses in the batch to debug the problemOk .. inserted a few pauses. Inserted one right before the msi ... I press enter and the script closes. Could the issue somehow be running it quietly? (Like I said, scripting isn't my thing .. I'm swinging in the dark here). Like I said .. it runs fine when I execute it by itself. Edited June 2, 2009 by BrandonW Link to comment Share on other sites More sharing options...
Developers Jos Posted June 2, 2009 Developers Share Posted June 2, 2009 Did you try the RunWait() with @Comspec? One other thing to try is to use /K to see whats happening: RunWait(@comspec ' /k "C:\Documents and Settings\user\Desktop\QS Install\Install.bat"') 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...
BrandonW Posted June 2, 2009 Author Share Posted June 2, 2009 Jos: I did use the @comspec and received a "Line -1: Error in expression", so I added & and I'm back to my previous issue with it closing at the msi.RunWait(@comspec & ' /c "C:\Documents and Settings\user\Desktop\QS Install\Install.bat"') Link to comment Share on other sites More sharing options...
Inverted Posted June 2, 2009 Share Posted June 2, 2009 (edited) I think I know why. The working directory is wrong. Try RunWait and set the Working directory to the same folder as the batch. Post the important lines of your autoit script also. Or try ShellExecuteWait if that doesn't work. Also try the @SW_MAXIMIZE and $RUN_CREATE_NEW_CONSOLE flags to see what's going on. Edited June 2, 2009 by Inverted Link to comment Share on other sites More sharing options...
BrandonW Posted June 2, 2009 Author Share Posted June 2, 2009 Interesting ... 'blah.msi' is not recognized as an internal or external command, operable program or batch file. Just to verify again, I ran the batch file immediately after getting that message. I think I just had a lightbulb click on. Ok ... so I moved by *.exe INTO the folder that is created with the script. Ran it and everything worked fine. So I'm guessing this is a dumb move on my part by not defining the paths better? Link to comment Share on other sites More sharing options...
BrandonW Posted June 2, 2009 Author Share Posted June 2, 2009 I think I know why. The working directory is wrong. Try RunWait and set the Working directory to the same folder as the batch. Post the important lines of your autoit script also.Or try ShellExecuteWait if that doesn't work. Also try the @SW_MAXIMIZE and $RUN_CREATE_NEW_CONSOLE flags to see what's going on.Ah you beat me to it. Link to comment Share on other sites More sharing options...
Developers Jos Posted June 2, 2009 Developers Share Posted June 2, 2009 Jos: I did use the @comspec and received a "Line -1: Error in expression", so I added & and I'm back to my previous issue with it closing at the msi. RunWait(@comspec & ' /c "C:\Documents and Settings\user\Desktop\QS Install\Install.bat"')Yea right ... needed that & in there. OK, so the batchfile shell an MSI after which it directly closes. I have seen that before and solved that by shelling the MSI using MSIEXEC.exe. Something like: msiexec /i "Name-of-msi.msi" 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...
BrandonW Posted June 2, 2009 Author Share Posted June 2, 2009 Woohoo! Got it done! Thanks for the help guys and putting up with yet another n00b. RunWait("C:\Documents and Settings\user\Desktop\QS Install\Install.bat", "C:\Documents and Settings\user\Desktop\QS Install") Link to comment Share on other sites More sharing options...
Inverted Posted June 2, 2009 Share Posted June 2, 2009 Don't use hardcoded paths like that, check the help file for the directory macros, so your script runs on all win installations. 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