MrBedo Posted November 3, 2004 Share Posted November 3, 2004 (edited) I'm fairly new to this AutoIT game and was just wondering if someone could help me out. I've got the following very basic script which simply runs an .exe if it finds it. The problem is, when it tries to run it I get a message saying 'Cannot find ini file'. If FileExists("C:\Program Files\Canon\PrnUninstall\PCL PrinterDriver\uninstal.exe") Then Run("C:\Program Files\Canon\PrnUninstall\PCL PrinterDriver\uninstal.exe") There is an ini file in the same folder as the exe, and if I run the exe the usual way by double clicking it then it runs fine. Do I have to call the ini file before the script runs the exe or something like that? Like I said, I'm new to all this 'automating the boring jobs' stuff! thanks in advance for any help Edited November 3, 2004 by MrBedo Link to comment Share on other sites More sharing options...
sugi Posted November 3, 2004 Share Posted November 3, 2004 Run("C:\Program Files\Canon\PrnUninstall\PCL PrinterDriver\uninstal.exe")Run() does not start a file. It tells windows to run a command line. If you enter what's between the quotes in your run statement into a command line window, it wont work for exactly the same reason.A correct command line would be:Run('"C:\Program Files\Canon\PrnUninstall\PCL PrinterDriver\uninstal.exe"')Compare the quotes to see the difference. Link to comment Share on other sites More sharing options...
Somerset Posted November 3, 2004 Share Posted November 3, 2004 expandcollapse popupFunction Reference Run -------------------------------------------------------------------------------- Runs an external program. Run ( "filename" [, "workingdir"[, flag]] ) Parameters filename The name of the executable (EXE, BAT, COM, or PIF) to run. workingdir [optional] The working directory. flag [optional] The "show" flag of the executed program: @SW_HIDE = Hidden window @SW_MINIMIZE = Minimized window @SW_MAXIMIZE = Maximized window Return Value Success: The PID of the process that was launched. Failure: Depends on RunErrorsFatal; see Remarks. Remarks To run DOS (console) commands, try RunWait(@ComSpec & " /c " & 'commandName', "", @SW_HIDE) After running the requested program the script continues. To pause execution of the script until the spawned program has finished use the RunWait function instead. By default the script will terminate with a fatal error if the Run function fails. To set @error to 1 as an indication of failure, see AutoItSetOption. Related RunAsSet, RunErrorsFatal (Option), RunWait Example Run("Notepad.exe", "", @SW_MAXIMIZE) hope this helps key words Working Directory read the bove... Link to comment Share on other sites More sharing options...
sugi Posted November 3, 2004 Share Posted November 3, 2004 hope this helps key words Working Directory read the bove...Sorry, but what has the Working Directory to do with his problem? Link to comment Share on other sites More sharing options...
MrBedo Posted November 3, 2004 Author Share Posted November 3, 2004 (edited) Thanks both for your help. Sugi - It didn't seem to make any difference by adding the ' ' around the statement, but I understand what you're saying. Beerman - Adding the working directory to the end of the statement seemed to do the trick and it now runs as it should. Thanks again to you both, especially for such quick replies! Edited November 3, 2004 by MrBedo joeadkins 1 Link to comment Share on other sites More sharing options...
Somerset Posted November 3, 2004 Share Posted November 3, 2004 Sorry, but what has the Working Directory to do with his problem?<{POST_SNAPBACK}>if a executable calls for an ini file or whatever else file. you have to denote which folder the executable is to be ran in so it knows where to look for the files that it is looking for. i hope i explained this correctly. Link to comment Share on other sites More sharing options...
sugi Posted November 3, 2004 Share Posted November 3, 2004 if a executable calls for an ini file or whatever else file [...]Sorry, my fault. I should have read the first post instead of simply guessing that it's the common problem with the quotes. Link to comment Share on other sites More sharing options...
scriptkitty Posted November 3, 2004 Share Posted November 3, 2004 Yea, the quotes (although in many cases are the first place to look for a mistake) are not the problem. I believe this might need a path as well, you could try one of these: If FileExists("C:\Program Files\Canon\PrnUninstall\PCL PrinterDriver\uninstal.exe") Then Run("C:\Program Files\Canon\PrnUninstall\PCL PrinterDriver\uninstal.exe","C:\Program Files\Canon\PrnUninstall\PCL PrinterDriver\") If FileExists("C:\Program Files\Canon\PrnUninstall\PCL PrinterDriver\uninstal.exe") Then Run("uninstal.exe","C:\Program Files\Canon\PrnUninstall\PCL PrinterDriver\") Specifying a path would be like running the program from that directory. You might also consider a Runwait() if you don't have to do anything in this process, but need to do something after. ( I usually use other functions like monitoring a window or proccess.) AutoIt3, the MACGYVER Pocket Knife for computers. 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