relative path to .Exe

418 Views Asked by At

I need to create a Batch file which has a relative path to a C# application executable. When I run the batch file the program needs to start regardless on which PC it is. Any help will be appreciated. Kind regards

1

There are 1 best solutions below

0
On

Let's try this. On your local machine, create this file. You need to know the machine name where the program currently resides and provide it as the first parameter. If the sharename could be different from C$, then it needs to be part of the parameter or another parameter.

=== runit.bat

@ECHO OFF
SETLOCAL
SET EXITCODE=0
PUSHD \\%1\C$\theprogdir
DIR

REM Replace this with starting the C# program
CALL thisistheprog.bat

SET EXITCODE=%ERRORLEVEL%
POPD
EXIT /B %EXITCODE%