I have a batch the would display usage if your parameter is invalid.
For ex.
Running "sample.bat update fuh"
:usageactions
set actions=%*
set toremove=update
set todisplay=%actions:%toremove% =%
echo Error: Invalid Arguments - '%todisplay%'.
echo Type sample.bat %toremove% -h for usage.
Expected Output:
Error: Invalid Arguments - 'fuh'.
Type sample.bat update -h for usage
But my output is:
Error: Invalid Arguments - 'update'.
Type sample.bat update -h for usage
How to achived it? Any help would be appreciated. Thanks.
(By the way, please modify the question if its so confusing.)
You try to expand an expression more than once in a line, but the parser can’t guess which percents are pairs.
You could use here delayed expansion
First %toRemove% will be expanded and then the line looks like
and then the exclamation expression will be evaluated.