Determine if executable is installed on Windows?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
jeff00seattle
Forum Commoner
Posts: 66
Joined: Sat Feb 28, 2009 3:27 pm

Determine if executable is installed on Windows?

Post 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
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Determine if executable is installed on Windows?

Post by AbraCadaver »

Code: Select all

if(file_exists('x:/path/to/the/executable.exe'))
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
jeff00seattle
Forum Commoner
Posts: 66
Joined: Sat Feb 28, 2009 3:27 pm

Re: Determine if executable is installed on Windows?

Post 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
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Determine if executable is installed on Windows?

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply