Reputation: 21
I'm trying to launch a specific ammount of the same batch file at the same time and I'm having trouble passing the parameters.
Here's the command I use:
START "Split lossless enc %%G" "%wrkdir%_menc.bat" "%wrkdir%%avs%_%%G.avs" "%wrkdir%%outf%_%%G.avi" "%menc%" "%mencx%"
%%G is a number(from 1 to 4 in my test)
%wrkdir% is the current working directory(so basically %~dp0)
%avs% and %outf% are both filename without extension
%menc% is a fullpath with filename and extension
%mencx% is a filename with extension
Any of those could potentially contain spaces but they don't in the test I've made so removing the surrounding quotes for the parameters works perfectly for now.
After all the searching I've done, everything tells me simply quoting the parameters should do the trick but I keep getting the following error: The filename, directory name, or volume label syntax is incorrect.
I've tried not using the parameters in the launched bat file to make sure it wasn't how I used it there that cause the problem(even though I very much doubted it), but it doesn't work even if it only contains ECHO it works
Edit: I forgot to say that the START is in a FOR loop that goes from 1 to 4 and that I use setlocal enableDelayedExpansion but all of the variable I use are set before it(except the %%G which obviously belongs to the FOR) and are outside of the loop
Edit2: To make it easier, I've stripped the batch file to the bare minimum(I tested it to make sure I got the same error) so I could give you the whole thing:
@ECHO off
SET wrkdir=%~dp0
SET avs=encode-01
SET menc=D:\_1enc_\_Tools\Mencoder\mencoder_r32198.exe
SET outf=test_mt
SET inst=4
SET mencx=%menc%
:FindMencx
IF NOT "%mencx:*\=%"=="%mencx%" (
SET "mencx=%mencx:*\=%"
GOTO FindMencx
)
FOR /L %%G IN (1,1,%inst%) DO (
START "Split lossless enc %%G" "%wrkdir%_menc.bat" "%wrkdir%%avs%_%%G.avs" "%wrkdir%%outf%_%%G.avi" "%menc%" "%mencx%"
)
Upvotes: 1
Views: 713
Reputation: 21
After a lot of trial and error, it seems that the START command doesn't work with quoted parameters when the bat file to launch is also quoted and contains its own path.
To work around the problem, I had to set the launch directory with the /D option(that I never noticed existed before) like so:
START "Split lossless enc %%G" /D"%wrkdir%" "_menc.bat" "%wrkdir%%avs%_%%G.avs" "%wrkdir%%outf%_%%G.avi" "%menc%" "%mencx%"
I also discovered that the same error was displayed when I input the wrong path so it seems it doesn't see it properly for some reason. No idea why it works fine with the path and bat file in quotes without parameters or with non-quoted ones though.
Edit: After including the fix in my full batch file, I realized that the launched batch file can't be surrounded with quotes if it's in the same directory as the current batch file, but it's ok if it's in a different one which is pretty weird. So to launch it from the same directory, I need to use _menc.bat
instead of "_menc.bat"
.
At least it works in both case when not quoted so that's good enough for me.
Upvotes: 0
Reputation: 31251
Without seeing the whole batch file with the for
loop I can only guess, but try adding a blank title after start
which, without it, can cause issues when the parameters have spaces.
START "" "Split lossless enc %%G" "%wrkdir%menc.bat" "%wrkdir%%avs%%%G.avs" "%wrkdir%%outf%_%%G.avi" "%menc%" "%mencx%"
Upvotes: 1