I'm doing a batch file to compile some dll, and well I have stuck on a simple but undetectable error...
Well, this is simple, I can't figure out why CMD is giving me this error, there is my code:
@echo off
::Call this in case your broke you dll and you cannot start Unity for example
:str
cls
goto :main
:main
echo Hello, well, if you're opening this is because you have done something wrong and you cannot start Unity...
echo.
set /p opt="Do you want to read your path from the 'path.txt' file or do you want to specify? [Y/N] "
echo.
echo Also, this is optional but you can try to establish an order for the compilation.
echo.
echo 1.- Build the API
echo 2.- Build the RAW Scripts
echo 3.- Build the Editor API
echo.
set /p order="Type, for example: [2 1 3], to compile in this order, or the way you want: "
if /i "%opt%" == "Y" (
for /f "delims=" %%f in ("project_path.txt") do (
if "%%f" NEQ "" (
call :callcompile "%%f" "%order%"
)
)
) else (
if /i "%opt%" == "N" (
echo.
set /p cpath="Path: "
goto :callcompile "%cpath%" "%order%"
) else (
goto :str
)
)
goto :EOF
:callcompile
cmd /c compile.bat "%~1" "%~2"
pause
Maybe, I'm missing something, but I can't see any fail in my code, maybe because of my inexperience, anyway, help me to solve it, because I have enclosed all the conditions and everything that could be causing a trouble without luck.
All the source can be seen here: https://github.com/Lerp2Dev/Lerp2API/blob/master/Compile/emergency_case.bat
Also, is there anyway to see the exact line where the error is causing the problem?
I didn't tested your code but at first sight it seems you have two syntax errors.
The first error is about the GoTo
statement, which only accepts one parameter, the label/sub-routine name, but you are trying to pass more than one parameter. Instead of GoTo
you can use Call
, or set/save the parameters into variables then call GoTo
only passing the label name and finally read the parameter values from your variables.
The second error, would be because you are not enclosing the CMD argument with quotes.
The right syntax to call the CMD as you want, would be like this:
CMD.exe /C "argument"
where in case of that you pass in an argument that represents a command that takes additional arguments that contains whitespaces, then they must be enclosed too, like this:
CMD.exe /C " script.bat "C:\path with spaces" "
Or also:
CMD.exe /C " Start /W "" "script.bat" "C:\path with spaces" "
So try like this:
CMD.exe /C " "compile.bat" "%~1" "%~2" "