0

I try this code :

start /d "D:\test\CONTOH\DATA\QGIS2\bin\" qgis.bat

based on : Bat file to run a .exe at the command prompt

But, I want to be relative path, something like this :

start /d %~dp0\DATA\QGIS2\bin\qgis.bat

based on : relative path in BAT script

but, nothing happen. So, can someone give me information, what is wrong?

Community
  • 1
  • 1
mega
  • 5
  • 3
  • 3
    If you compare your commands you can see that your first command has three arguments after the `start` but your second command only has two – MC ND Feb 14 '17 at 07:03
  • 4
    start takes the first parameter in double quotes as the window title. Insert an empty dummy pair to avoid this. –  Feb 14 '17 at 08:32

1 Answers1

1

Open a command prompt window and run start /?. This outputs the help for the command START which should be read on using this command to get knowledge about its options.

Run in command prompt window call /? and read the output help pages to understand %~dp0. The drive and path of the batch file (argument 0) always ends with a backslash. Therefore don't add an extra backslash on concatenating it with another string.

And the first double quoted string is interpreted by START as title for the new console window displayed in title bar of the new window. Therefore better specify always a title string which can be also an empty string like "" in case of starting a GUI application on which no console window is opened at all.

start "Running QGIS2" /D "%~dp0DATA\QGIS2\bin" qgis.bat

Also possible is using this command line in batch file:

start "Running QGIS2" /D"%~dp0DATA\QGIS2\bin" qgis.bat

Here start in directory as defined with /D"%~dp0DATA\QGIS2\bin" is 100% correct specified according to help of command START as one parameter string.

But Windows command interpreter accepts also the first variant with just option /D without any folder path and next parameter string "%~dp0DATA\QGIS2\bin" after a separating space is the folder path for start in directory.

The first variant with just /D as one parameter string and "%~dp0DATA\QGIS2\bin" as one more parameter string is easier to read in comparison to second variant with /D"%~dp0DATA\QGIS2\bin" being just one parameter string.

Mofi
  • 46,139
  • 17
  • 80
  • 143