Batch file - What is the root folder when using -f

1k views Asked by At

I would like to know what is the root folder when calling, for example, mvn, when the pom.xml file is located in inner folder?

For example, if my current folder path is c:\projects\project, which contains the batch/cmd file. And the there is an inner folder (under project), called "module", which contains the pom.xml file.

When i'm writing in the cmd file:

call mvn clean install -f modules/refersh-client-war  -nsu -B

It looks for folder "modules" under c:\windows\system32.

I fixed it by adding "%0/../" in the begging of the file path:

call mvn clean install -f %0/../modules/refersh-client-war  -nsu -B

why, when not defining a full path, the default is "c:\windows\system32", is it taken from an environment variable? Is it the default root folder for cmd files?

Thanks, Meir

1

There are 1 answers

0
PA. On

you are asking for the default directory.

You may access it thru the %CD% environment variable. Try echo %CD%.

You can change it with the PUSHD command from inside your batch file. Try pushd %~dp0.

It is usually set in the shortcut you use to open your command prompt or the shortcut you use to start your .BAT file. Check it under the shortcut tab of the properties of the shortcut, in the start in: field; you may change it there as well.