Notifications
Clear all

[Closed] 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.

3 Replies

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

does it have a registry value you can query ?

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

edit yes…

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.

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

 [/left]

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.