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
Determine if executable is installed on Windows?
Moderator: General Moderators
-
jeff00seattle
- Forum Commoner
- Posts: 66
- Joined: Sat Feb 28, 2009 3:27 pm
- 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?
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?
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
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
- 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?
The only thing I can think of is the COM extension: http://us.php.net/manual/en/book.com.phpjeff00seattle 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
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.