WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: NickL on January 09, 2014, 01:43:20 AM

Title: Finding the path to the running executable
Post by: NickL on January 09, 2014, 01:43:20 AM
Hi.

I'm running a compiled WinBatch script on a server share and I need to call another executable in the same folder - however the folder name is not static and can change, so what I'm after is a command or function that tells me the path that the currently running script has been run from.

I've looked through the functions manual but can't find anything that does this.

Any help would be much appreciated.
Title: Re: Finding the path to the running executable
Post by: snowsnowsnow on January 09, 2014, 03:28:12 AM
Have you tried IntControll(1004)?  I think (but am not sure) that if you are running as compiled EXE, that will give you the full path to your EXE.

Alternatively, you can use WMI and the Win32 Process class to get the "Name" attribute of any process.
Title: Re: Finding the path to the running executable
Post by: NickL on January 09, 2014, 05:23:18 AM
IntControl(1004,0,0,0,0)  works a treat - that's exactly what I was after.  Thanks very much :-)
Title: Re: Finding the path to the running executable
Post by: Deana on January 09, 2014, 08:33:48 AM
Quote from: NickL on January 09, 2014, 01:43:20 AM
Hi.

I'm running a compiled WinBatch script on a server share and I need to call another executable in the same folder - however the folder name is not static and can change, so what I'm after is a command or function that tells me the path that the currently running script has been run from.

I've looked through the functions manual but can't find anything that does this.

Any help would be much appreciated.

The best function to use to obtain the directory the script is running from is DirScript().