Home > OS >  Run script from another directory in windows command line
Run script from another directory in windows command line

Time:10-04

I'm trying to run a script like this

../../dirA/dirB/run.bat

The reason why I do that and not run the script directly is that this exact line above is called from another software and I cannot do it differently. The software does not support running cmd in different directory, only supports starting cmd and running one command - that's what I do.

The issue is, cmd throws this error:

'..' is not recognized as an internal or external command,
operable program or batch file.

One way to work around this is to put another batch script into the software folder - this script then would call another script, in batch i can use

call ../../dirA/dirB/run.bat

But is there a different way - cleaner? Is there a way to call ../../dirA/dirB/run.bat from cmd directly?

I have to mention that I cannot specify an exact path on exact drive - the drive is a clearquest dynamic view, therefore every user can mount it under a different letter, with different name, that is why I need the .. method.

I only know where it is relative to current directory.

CodePudding user response:

The result seems to be - it is not possible when done in cmd directly. I will get the same result with a workaround - creating another batch file in the directory, then call the script from here.

CodePudding user response:

I have the same error ... when I run your command directly from the main drive (like from "C:"). You should be aware that ".." is the parent directory, so you must be located inside some subsubdirectory (the are two ".."s).

  • Related