Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello to all:
I'm having a little problem with 2 batch files I have. I will refer to them as 1.bat and 2.bat What I would like to complish is as follows. I run a weekly report off 2.bat, it is in it's own directory and the results are placed in there. My 1.bat file is used to find other data. I included the command in my 1.bat to call 2.bat. 2.bat runs fine, but the only problem I'm having is that the results are getting put in 1.bat's directory and not in 2.bat directory. Is there a way I can tell my 1.bat file to call 2.bat and the results that generate. To write out the results in 2.bat directory?
Another thing related to this is the following. In 2.bat's directory there is a prog called psort.exe. The prog runs fine when I run 2.bat from it's own directory, but when it is called from 1.bat. The psort.exe file does not run. Therefore not psorting out the results. I copied the file in my 1.bat's directory and the program runs, but can I make it run from 1.bat's directory instead, when 2.bat is called?Thank You for your time

If 1.bat and 2.bat are in different directories, I would try putting in 1.bat a line before 2.bat is called that says "cd\batfile2dir" so that when 2.bat is run, it is run in its own directory. I take it that you have batfile2dir\2.bat as your execution of 2.bat wiht all this. Basically, you need to run 2.bat from it's own directory. Same deal with the other program, it needs to run in it's own directory.
I think this is an answer to your problem, I think.

Yeah, probably 2.bat simply stores data to files without specifying their path, so the files are created on the current directory (which is not necessarily the batch file's directory).
As Robbobob said, a solution would be to change to 2.bat's directory before CALLing it:
pushd c:\2batdir
call 2.bat
popdThat would change to the directory c:\2batdir (representing the directory where 2.bat is located), call 2.bat and then return to the original directory.
Another solution would be to modify 2.bat, so it refers to files with determined paths. Let's say there's something like this on 2.bat:
echo Log begin>> logfile.txt
You would modify that to:
echo Log begin>> c:\2batdir\logfile.txt
Or perhaps:
echo Log begin>> %0\..\logfile.txt
Nevertheless, the first solution is probably simpler.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |