Search This Blog

Thursday, June 17, 2010

Running Batch file from network location

I develop a java tester tool for our testers , and to avoid installing java run time on their machines, i create a directory in the network and copy there the java run time with my specific jars.
to make the life easier i create a batch file to run the tester tool.
hammmm , when i tried to run the batch file i get the next error on the next command  cd .\java\bin,
“CMD does not support UNC paths as current directories“.

i solved it by the next command: "pushd %~dp0\java\bin"
the %~dp0  is to Get the Directory Path of an executing Batch file
dont forget in the end use POPD command .

i have put all the stuff on the network e.g. \\server1\tester\
so finally my batch file looks like this :
@ECHO OFF
pushd %~dp0\java\bin
java -DPARAM1=../../param.config -jar ../../param.jar %1
popd
pause

enjoy
Yaniv T

No comments: