Get DCC executable from hook

Hello,

Is it possible to get the DCC executable that was used to launch the app from inside a hook? For example, if the hook is being executed in Maya 2018, the executable I’m looking for would be “C:\Program Files\Autodesk\Maya2018\bin\maya.exe”.

Thanks!

3 Likes

You can get the path in the “app_launch” hook for the tk-multi-launchapp.
https://github.com/shotgunsoftware/tk-multi-launchapp/blob/master/hooks/app_launch.py

2 Likes

Hi @Patrick, thanks for the reply. As far as I understand, to execute the app_launch hook I already need to know the app_path:

def execute(self, app_path, app_args, version, engine_name, **kwargs)

My situation is that I’m in a custom hook that doesn’t inherit from AppLaunch and I want to find out the executable that was used to start the DCC given that I know the custom hook parent’s engine, context, etc.

Any ideas?

1 Like

Use the hook I suggested and stick the value in an env var that you can then query from your other hook. The env var set when you app_launch should persist to your other hook.

3 Likes

Good idea, thanks @Patrick :slight_smile:

1 Like

Also, it looks like Maya sets its own env var as well MAYA_LOCATION.
For me on Mac that returns /Applications/Autodesk/maya2021/Maya.app/Contents, I’m not sure what it would give you on Windows.

1 Like

Thanks for the input @philip.scadding. On Windows it gets you “C:/Program Files/Autodesk/Maya20XX” so it doesn’t get you the executable. Also, I needed a DCC-agnostic solution so I’ve gone with setting a custom environment variable in the AppLaunch hook.

3 Likes