|
Answer» Ok, Hi! This is my first topic here, so I will go to the point directly: I have this Batch FILE: ---------------------------------------------------------------------------------------
@echo off :checkstage IF "%0"=="%0" goto comparch IF "%1" == "help" goto 1 IF "%1"=="emulate" goto 2 IF %2== goto 3
:comparch echo Comparch v1.0 echo 2015 (C) uSoft. All Rights Reserved. cd.. call shell.bat
:1 echo Usage Description echo ===== =========== echo comparch help Displays help about commands echo comparch emulate [file] Displays help about commands cd.. call shell.bat
---------------------------------------------------------------------------------------
That file is called by another batch file, shell.bat. And it is like this:
---------------------------------------------------------------------------------------
@echo off title Comparch v1.0 Shell :shell cd bin set/P cli= *
IF %cli%==comparch call comparch.bat
---------------------------------------------------------------------------------------
So, my problem is that when I type, for example, comparch help, it displays:
help== was not expected at this time
And it leaves instantly.
What is wrong?
Pd: When I type "comparch" alone without any parameters, it runs correctly...Look at your test for %2TO clarify
This line:
IF %2== goto 3
will break the script if there is no second parameter passed to the script (if %2 is empty when the script is RUN) This is because you must have something on both sides of the == in an IF test. The usual way to beat this is to use quotes like this
IF "%2"=="" goto 3
Also,
When this line is run:
set/p cli= *
However if the user just hits ENTER so set /p captures an empty string, then this line:
IF %cli%==comparch call comparch.bat
will break the script because %cli% will be empty so do this:
IF "%cli%"=="comparch" call comparch.bat
This will fail if the user types the answer using any upper case characters. I am sure you can find out how to get around this, if the boast in your sig is true.
Finally, what is this line supposed to do?
IF "%0"=="%0" goto comparch Thank you, and... "%0==%0" It was 2 AM, I didn't even wanted to think anymoreQuote from: BatchProgrammer on October 29, 2015, 04:02:49 PM It was 2 AM, I didn't even wanted to think anymore I've been there...
|