Computing.Net > Forums > Disk Operating System > run batch file in non-current directory

run batch file in non-current directory

Reply to Message Icon

Original Message
Name: leo
Date: August 2, 2002 at 08:43:00 Pacific
Subject: run batch file in non-current directory
Comment:

I have a Java program and a batch file command to run the java program. It works well if I run it in its own directory, say C:\update.

But when I run it in other directories with command like " C:\update\myBat.bat".

It shows that "main" method is not found. Why and how I can make it run?

Thanks
"


Report Offensive Message For Removal


Response Number 1
Name: Tim
Date: August 2, 2002 at 10:09:04 Pacific
Reply: (edit)

You can try and put C:\update in the PATH.


Report Offensive Follow Up For Removal

Response Number 2
Name: Secret_Doom
Date: August 2, 2002 at 10:48:33 Pacific
Reply: (edit)

My guess is that either the batch or the java program are looking for a file on the current directory, and the file is only present on the c:\update directory.

I interpret such a thing as a programming error, since it's a quite reasonable possibility that the batch file or java program is run from another directory.

You can change the current directory to C:\UPDATE, run the java program and then go back:

@echo off
echo @PROMPT $N:$_CD "$P$_> %TEMP%.\T1.BAT
%COMSPEC% /C %TEMP%.\T1.BAT > %TEMP%.\T2.BAT
del %TEMP%.\T1.BAT
C:
CD C:\UPDATE
call javaprog
for %%? in (call del) do %%? %TEMP%.\T2.BAT

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: run batch file in non-current directory

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge