First check for missing parameters, then assign and process the command:
IF .%1 == . ( echo "Input argument missing: command" GOTO :eof ) SETLOCAL set CMD=%* echo Running command [%CMD%] echo "XXX %CMD%"
As for “Why?”, This is because the quotation mark in the CMD value (before a ) closes the quotation mark before %CMD% , and therefore the string appears as "echo "abc"" , and thus b becomes separated from the string, which crashes the command processor. (He expects a comparison token, e.g. == or EQU , but not some weird b ).
source share