Check if external program installed?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  02 February 2013
Check if external program installed?

I've written a maxscript utilising the external command line image manipulation program graphicsmagick. What would be a good way of checking if this program is installed from maxscript?

I was thinking of using
hiddendoscommand "gm" > tempfile 
then examine the tempfile contents for the results. But that seems a bit overly hacky and open to file permission errors. Is there a better way that I could do this without using a tempfile?

Cheers,
Cg.
__________________
Not bad. For a hughman.
 
  02 February 2013
For your command to work, the executable would have to be in an environment PATH variable. You could either check the PATHs themselves, or scan for gm.exe in those paths.

For example,
(for p in (filterString (systemTools.getEnvVariable "PATH") ";") where doesFileExist (p+"\\gm.exe") collect p).count > 0

or the more verbose form

thePathString  = systemTools.getEnvVariable "PATH" --get env. variable
thePathsArray = filterString thePathString ";" --get array of path definitions
--Collect all paths that contain gm.exe
theGMPaths = for p in thePathsArray where doesFileExist (p+"\\gm.exe") collect p
print theGMPaths --> print the paths that contain gm.exe
theGMPaths.count > 0 --> True if any path contained gm.exe
__________________
Bobo

Last edited by Bobo : 02 February 2013 at 08:15 AM.
 
  02 February 2013
does it have a registry value you can query ?

registry.queryValue <HKey>   type:<&name> value:<&value> expand:<bool>


edit yes....



Quote: When GraphicsMagick is installed, entries are added to the Windows Registry so that other programs may obtain information regarding the most recently installed GraphicsMagick. These entries are available under the registry path HKEY_LOCAL_MACHINE\SOFTWARE\GraphicsMagick\Current .


Quote:
These registry keys are currently available:

BinPath REG_SZ Directory where GraphicsMagick executables are installed

ConfigurePath REG_SZ Directory where configuration files are installed

LibPath REG_SZ Directory where GraphicsMagick core DLLs are installed

CoderModulesPath REG_SZ Directory where GraphicsMagick loadable coder modules are installed

FilterModulesPath REG_SZ Directory where GraphicsMagick loadable filter modules are installed

SharePath REG_SZ Directory where configuration files are installed


Last edited by Klunk : 02 February 2013 at 10:42 AM.
 
  02 February 2013
Thank you both. I definitely have some options to explore there. Annoyingly, I only just realised that graphicsmagick doesn't seem to support exr. Which I find baffling. Looking into imagemagick instead as it seems to support exr. I'm sure it also has environment variable paths and registry entries. I appreciate your indepth answers.

Cheers,
Cg.
__________________
Not bad. For a hughman.
 
  02 February 2013
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 09:13 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.