Page 1 of 1

Determine if executable is installed on Windows?

Posted: Wed Jan 27, 2010 8:48 pm
by jeff00seattle
Hi

In PHP, what would be the best way to determine if an executable is installed within a Windows environment before actually calling the executable using shell exec()?

Thanks

Jeff in Seattle

Re: Determine if executable is installed on Windows?

Posted: Wed Jan 27, 2010 9:57 pm
by AbraCadaver

Code: Select all

if(file_exists('x:/path/to/the/executable.exe'))

Re: Determine if executable is installed on Windows?

Posted: Wed Jan 27, 2010 10:57 pm
by jeff00seattle
Thanks for the reply, but...

What if you are creating an open PHP script to be used by another user, then the expected path would not be known.

So, since there is no expected path for the executable, then file_exists() would not work.

Jeff in Seattle

Re: Determine if executable is installed on Windows?

Posted: Wed Jan 27, 2010 11:04 pm
by AbraCadaver
jeff00seattle wrote:Thanks for the reply, but...

What if you are creating an open PHP script to be used by another user, then the expected path would not be known.

So, since there is no expected path for the executable, then file_exists() would not work.

Jeff in Seattle
The only thing I can think of is the COM extension: http://us.php.net/manual/en/book.com.php

It's been a while since I coded for Windows, and even then I didn't know everything that is exposed, but whatever is exposed by COM (whether searching drives, registry keys, etc...) you should be able to find. You would definitely need to know something about Windows dev and where to look/what to look for, but it should definitely be doable.