Hello,
Was wondering if anyone was aware of a way of finding out which directory your batch file (wrapped in exe) is being executed from?
This is useful if you need to run an application that resides in the same directory as the exe file. Since the batch file is unwrapped to your temp directory before being executed, attempting to find the current working directory via batch commands won't get you the correct result.
Thanks.
the directory your batch is being executed from
-
- Posts: 6
- Joined: Sun May 21, 2006 4:55 am
-
- Posts: 3
- Joined: Sun May 21, 2006 1:10 am
Thanks daslik, that works. Seems like I was trying to overcomplicate things hence the problem I was getting.
My operating system is windows xp but I was wondering if you knew for sure whether that command would work on older versions of windows as well (e.g. windows 2000, etc)?
Some of my users have not updated their machines in ages!
My operating system is windows xp but I was wondering if you knew for sure whether that command would work on older versions of windows as well (e.g. windows 2000, etc)?
Some of my users have not updated their machines in ages!
-
- Posts: 6
- Joined: Sun May 21, 2006 4:55 am
-
- Posts: 5
- Joined: Tue Apr 24, 2007 10:06 pm
I know this is dead, but for future readers:
relative paths will help you here...
If your batch file (compiled or not) is located in C:\dir1\dir2, you don't need to enter C:\dir1\dir2\file.exe to run file.exe from your batch script. just enter file.exe. as long as the file exists, it'll work. If file.exe is in dir1, and your batch in dir2, you can use ..\file.exe. If your batch is in dir1, and your exe is in dir2, you can use dir2\file.exe.
you can also use
IF EXIST file.exe (file.exe) ELSE (echo Error - file not found).
google relative paths for more info
relative paths will help you here...
If your batch file (compiled or not) is located in C:\dir1\dir2, you don't need to enter C:\dir1\dir2\file.exe to run file.exe from your batch script. just enter file.exe. as long as the file exists, it'll work. If file.exe is in dir1, and your batch in dir2, you can use ..\file.exe. If your batch is in dir1, and your exe is in dir2, you can use dir2\file.exe.
you can also use
IF EXIST file.exe (file.exe) ELSE (echo Error - file not found).
google relative paths for more info