DOS Bat with %1 - How to detect this as Error in Bat file? - TechRepublic
General discussion
October 14, 2004 at 05:10 AM
ken.roberts

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

by ken.roberts . Updated 21 years, 9 months ago

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?

This discussion is locked

All Comments