tyh
tyh

Reputation: 1007

Batch Closing before end of file?

I am trying to create a batch to automate commands for something. Right now I am just running a single command and the batch closes right after it prints the output from the command. I put a PAUSE in at the end but it keeps running past it. This is probably something very simple that I am just missing.

@echo
set /p ticket="Enter ticket number: "
tkt get %ticket%
PAUSE

The tkt get %ticket% part is from a custom utility I am using. That part is definitely formatted properly because I use it through command prompt every day almost. I want to automate a lot of my normal commands to make life easier.

Upvotes: 0

Views: 544

Answers (1)

JohnD
JohnD

Reputation: 14767

Is "tkt" a batch file? Try making it "call tkt" instead.

If you call a batch file from another, the first one will exit after executing the 2nd one, unless it is called with "call".

Here's an example:

Foo1.bat

foo2.bat
echo foo1

Foo2.bat

echo foo2

It seems like if you run Foo1.bat, it will spit out both "foo1" and "foo2" but it does not:

C:\temp>foo1

C:\temp>foo2.bat

C:\temp>echo foo2
foo2

To change the behavior, Foo1.bat should look like this:

foo1.bat

    call foo2.bat
    echo foo1

Upvotes: 2

Related Questions