I have a batch script that can run either a normal or differential backup. I have the file test.bat, which I want to be ran in conjunction with a switch. For example, "test.bat /norm" to run a normal backup and "test.bat /diff" to run a differential backup.
Take a look at the code to see what I have. If I REM out the first line code works well enough, if the switches are /norm or /diff they go to the right place and if there is any other switch they get the "%1" is not a valid switch." message, though obviously not using any switch makes the code error out with an unexpected GOTO.
With the code exactly as it is below it seems as if the code always assumes that the %1 is null for some reason, regardless if a switch is actually specified or not. It always goes to the :btnull block every time.
Any thoughts?
if not defined %1 GOTO :btnullif %1==/norm GOTO :btnormif %1==/diff GOTO :btdiffecho "%1" is not a valid switch.echo.echo Accepted switches:echo /norm = Start a Normal backup.echo /diff = Start a Differential backup.echo.pauseexit:btnullecho This script must be supplied a valid switch.echo.echo Accepted switches:echo /norm = Start a Normal backup.echo /diff = Start a Differential backup.echo.pauseexit:btnormset backuptype=NormalGOTO :btend:btdiffset backuptype=DifferentialGOTO :btend:btend