Pop Quiz: The syntax of the command is incorrect.
Had a hair pulling ten minutes just now. A simple batch script code fails to run. And I had a difficult time figuring it out. The following is a much simplified brain teaser for you. Can you figure out what's wrong?
The code above produces the following output:
Why? What's wrong with the if statement? Let see if you know the answer. I'll post the lesson learned in a few days.
The error actually occurred before the if statement, which was why I was pulling my hair out. In the set variable statement, before the echo statement, there was an extra double-quote at the end of the statement. That caused the failure in the if statement.
Lesson learned in this case is that DOS/Windows batch interpreter is quite rudimentary in its error messages. So, just looking at the line that produces the error message may not be sufficient. You have to look at surrounding statements. In more complex batch scripts, digging deep into the variable value could be a speedier way of debugging.
Did your message disappear? Read the Forums FAQ.
Spam Control | * indicates required field
No TrackBacks yet. TrackBack can be used to link this thread to your weblog, or link your weblog to this thread. In addition, TrackBack can be used as a form of remote commenting. Rather than posting the comment directly on this thread, you can posts it on your own weblog. Then have your weblog sends a TrackBack ping to the TrackBack URL, so that your post would show up here.
Messages, files, and images copyright by respective owners.
16 Users Online
Copyright © 1996 - 2017. All Rights Reserved.