Discussion Locked

DOS Bat with %1 - How to detect this as Error in Bat file?

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a simple DOS batch file, "copyin.bat" that has one variable, which is referenced by %1. The variable is the user's own directory on our server. So if John wants to copy in my files to his directory, he just enters: "copyin John".

However, sometimes the user will forget and just run the batch file without the variable, typing in "copyin" all by itself. How can I use the ErrorLevel variable or some other method to detect this and then issue this:

Echo You forgot to enter your Name - please rerun the program

Any ideas?

1 reply

by jackofalltech

Ten (even five) years ago, I wouldn't have believed anyone would ask this question but things change ;-)

If '%1'=='' Goto Syntax
.
.
.
Goto Done

:Syntax
Echo ERROR....

:Done

This discussion is closed to new replies.