.BAT Switches Parsing
- by giiYanJ
Erm.. I'm working with a switches parsing in BAT files, which goes like this:
<commands> -a -b -x -y -z -u abc ......
The user may input a lot of switch, or none. So I used looped shift to make parsing infinite switches possible:
:loop
IF "%1"=="-a"
...
SHIFT
GOTO loop
But when the script ends, I always get cmd executing the switches and showing up error like
'-n' is not recognized as an internal...
So, someone got any idea? Thanks a lot...
P/S: Make solution sticks with BAT script if possible as using other language may cause dependencies problem as this script is aimed on ANY computer with Windows.
Finally, thanks again =)
EDIT: Tried shf301 suggestion, i found out that I used DEL %0 to delete itself but it seems the %0 is shifted into the arguments because of the SHIFT command.