Sign in to follow this  
Followers 0
Noob

How to check if notepad.exe exists (without knowing the path)

14 posts in this topic

Some programs can be started just by clicking Start > Run> and typing for example notepad.exe

I was hoping to be able to use If FileExists("notepad.exe") but that doesn't work. Is there another way?

Thank you.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

So you want to be able to have the computer search for a program?

or check if it's in use?

Edited 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

Share this post


Link to post
Share on other sites

iF ProcessExists()

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

ahh ok i get it...

Share this post


Link to post
Share on other sites

I have found a different solution to my problem :) It uses RegRead()

Thanks all, especially Zedna, for your time and kind help.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0