Abyssmedia.com Forum Index Abyssmedia.com
Abyssmedia Support Forums
 
  FAQ    Search    Memberlist    Usergroups   Register 
  Profile    Log in to check your private messages    Log in 

the directory your batch is being executed from

 
Post new topic   Reply to topic    Abyssmedia.com Forum Index -> Quick Batch File Compiler
View previous topic :: View next topic  
Author Message
amrs



Joined: 21 May 2006
Posts: 3

PostPosted: Sun May 21, 2006 1:16 am    Post subject: Reply with quote

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.
Back to top
daslick



Joined: 21 May 2006
Posts: 6

PostPosted: Sun May 21, 2006 4:59 am    Post subject: Reply with quote

You could use the following commands, depending on what you mean by find out.
cd>%tmp%/batchloc.txt (would send the location to the contents of the temporary folder/batchloc.txt)

or
set batchloc=%cd%
echo %batchloc%
Back to top
amrs



Joined: 21 May 2006
Posts: 3

PostPosted: Sun May 21, 2006 10:57 am    Post subject: Reply with quote

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!
Back to top
daslick



Joined: 21 May 2006
Posts: 6

PostPosted: Tue May 23, 2006 3:05 am    Post subject: Reply with quote

It will work with 2000... Not so sure about 95/98... research it if you have machines with those.
No Problem Very Happy
Back to top
overkill



Joined: 24 Apr 2007
Posts: 5

PostPosted: Tue Apr 24, 2007 10:15 pm    Post subject: Reply with quote

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 Very Happy
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Abyssmedia.com Forum Index -> Quick Batch File Compiler All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001-2011 phpBB Group