2
START "Test Server" "%~dp0\server.exe" LAN %M%.aao log=server.log ini=server.ini

Everything after "LAN" is not being executed by server.exe I can see in the servers log file that it is trying to open lan but it should be trying to open %m%.aao which means everything after "LAN" is being ignored.

How can I fix this?

Using

START "Test Server" server.exe LAN %M%.aao log=server.log ini=server.ini

will not work as I'm trying to run the batch file from WOTGreal. I am unsure why, but the way I fixed it for the other two files/programs I open was to use %~dp0, but the server requires that the spaces not be ignored.

Mofi
  • 46,139
  • 17
  • 80
  • 143
LEEFFM
  • 17
  • 4
  • If the string hold by environment variable `M` contains a space or one of these characters ``&()[]{}^=;!'+,`~``, you must use `"%M%.aao"`. – Mofi Aug 20 '16 at 09:33
  • And change `"%~dp0\server.exe"` to `"%~dp0server.exe"` because the drive and path of the batch file referenced with `%~dp0` always ends already with a backslash and therefore adding one more backslash results on execution on two backslashes in series in path to `server.exe`. The Windows kernel functions correct this error in path, but it is not good to specify the path to an executable wrong. – Mofi Aug 20 '16 at 09:37

1 Answers1

0

I'm trying to run the batch file from WOTGreal

So the batchfile will be run from a different folder. That will also mean server.exe will be run from a different folder. so local filenames like in %M%.aao log=server.log ini=server.ini will be read from the wrong directory.

You could probably fix that by also using %~dp0 in all other paths. But it is probably easier to change the current directory at the start of the batchfile. To do that, add the following line to the start of the batchfile.

cd /d "%~dp0"
wimh
  • 15,072
  • 6
  • 47
  • 98