Noob Posted January 13, 2007 Posted January 13, 2007 Some programs can be started just by clicking Start > Run> and typing for example notepad.exeI was hoping to be able to use If FileExists("notepad.exe") but that doesn't work. Is there another way?Thank you.
BALA Posted January 13, 2007 Posted January 13, 2007 (edited) So you want to be able to have the computer search for a program? or check if it's in use? Edited January 13, 2007 by BALA [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Paulie Posted January 13, 2007 Posted January 13, 2007 iF ProcessExists()8)and to elaborate a little bit...http://www.autoitscript.com/autoit3/docs/f...ocessExists.htm
James Posted January 13, 2007 Posted January 13, 2007 Do you mean like the run box? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Noob Posted January 13, 2007 Author Posted January 13, 2007 My problem is that I need to find out if the actual *.exe exists (without it running at the moment). I've created a (free) add-on application which automates the usage of Microsoft Streets & Trips. It is a mapping and GPS navigation program with North American maps. I also created another such application for the European version of the program called AutoRoute. Now I plan on joining the two AutoIt applications into one. I want the script to be able to (upon startup) detect if Streets.exe exists or AutoRout.exe exists. I know the default installation path for both AutpRoute and Streets & Trips, but users may change the default path. Any ideas? I know I can let users select which program they use, but I'd rather automate this.
Zedna Posted January 14, 2007 Posted January 14, 2007 Opt('RunErrorsFatal',0) $exe = 'notepad.exe' $pid = Run($exe,'',@SW_HIDE) If @error Then $answer = $exe & ' not exist' Else ProcessClose($pid) $answer = $exe & ' exist' EndIf MsgBox(0,'Answer', $answer) Resources UDF ResourcesEx UDF AutoIt Forum Search
Noob Posted January 14, 2007 Author Posted January 14, 2007 Wow, Zedna, I thank you very much! I just spent a couple of hours on it again, with disapointing resuls. Your script seems the best solution. I needed to substitute RUN for ShellExecute to make it work with the two intended programs. It works fine. One little annoyance is that the programs display their splashscreen for their usual 6 seconds. After that the programs are out of sight. But this should not be an issue as this only will be needed one time, when a user runs the script the first time. Again, I thank you very kindly, Zedna.
Noob Posted January 14, 2007 Author Posted January 14, 2007 Hmm, while the script works flawlesly the way you wrote it, there is a problem when I substitute RUN with ShellExecute. (Run doesn't start the two programs so I use ShellExecute instead.) The problem is that I'm getting Windows error telling me Windows cannot find the *.exe file. I don't know how to close the error pop-up. I tried AdlibEnable, but it doesn't seem to work (I may be doing something wrong). The script gets stuck at the line: $pid = ShellExecute............ Opt ("TrayIconDebug", 1) Opt('RunErrorsFatal',0) AdlibEnable("myadlib") $exe = 'notepad1.exe' $pid = ShellExecute($exe,'',@SW_HIDE) If @error Then $answer = $exe & ' not exist' Else ProcessClose($pid) $answer = $exe & ' exist' EndIf MsgBox(0,'Answer', $answer) Func myadlib() If WinExists("", "Windows cannot find") Then ControlClick("", "Windows cannot find", "Button1") EndIf EndFunc
BrettF Posted January 14, 2007 Posted January 14, 2007 Whats wrong with this line? $exe = 'notepad1.exe' For some reason there's a 1... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Noob Posted January 14, 2007 Author Posted January 14, 2007 I put it there purposly. The script is to test whether or not an *.exe exists. notepad1.exe doesn't exist. When you run the script you will see the Windows error I'm getting. I'm now trying to find a way to close that Windows error pop-up
BrettF Posted January 14, 2007 Posted January 14, 2007 I put it there purposly. The script is to test whether or not an *.exe exists. notepad1.exe doesn't exist. When you run the script you will see the Windows error I'm getting. I'm now trying to find a way to close that Windows error pop-upahh ok i get it... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Zedna Posted January 14, 2007 Posted January 14, 2007 Whats wrong with this line? $exe = 'notepad1.exe' For some reason there's a 1... It's there to simulate not existing file. Resources UDF ResourcesEx UDF AutoIt Forum Search
Noob Posted January 14, 2007 Author Posted January 14, 2007 I have found a different solution to my problem It uses RegRead() Thanks all, especially Zedna, for your time and kind help.
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