# Solved: Batch File Help - Won't "exit"



## jimi (Jun 14, 2000)

ok guys this one has me stumped, the following is a batch file thats run on a schedule.

C:\E-Com\EC-Connect\ECConnectsched.exe START
exit

the next is a screen shot of what happens when it's run, making me hit the X in upper right - any ideas??? , i want it to shut the window by itself.


----------



## Squashman (Apr 4, 2003)

start goes in front of the file you want to execute.


----------



## brendandonhu (Jul 8, 2002)

Are you using Windows 95/98?
If so, find the *.bat file, Right Click>>Properties>>Programs>>Close On Exit>>Apply>>OK


----------



## jimi (Jun 14, 2000)

thanks guys, start didn't work, brendan already had done what you suggest, and yes it's 98se, here's what did work

C:\E-Com\EC-Connect\ECConnectsched.exe START
@ echo off
cls
exit

been awhile since i wrote a batch pgm


----------



## ChuckE (Aug 30, 2004)

Good that you resolved you issue, but I have a question:
Why do you have START at the end of the line?
What do you think it is doing?

According to the help on START it says:

```
C:\>start /?
Starts a separate window to run a specified program or command.

START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
      [/WAIT] [/B] [command/program]
      [parameters]

    "title"     Title to display in  window title bar.
    path        Starting directory
    B           Start application without creating a new window. The
                application has ^C handling ignored. Unless the application
                enables ^C processing, ^Break is the only way to interrupt
                the application
    I           The new environment will be the original environment passed
                to the cmd.exe and not the current environment.
    MIN         Start window minimized
    MAX         Start window maximized
    SEPARATE    Start 16-bit Windows program in separate memory space
    SHARED      Start 16-bit Windows program in shared memory space
    LOW         Start application in the IDLE priority class
    NORMAL      Start application in the NORMAL priority class
    HIGH        Start application in the HIGH priority class
    REALTIME    Start application in the REALTIME priority class
    ABOVENORMAL Start application in the ABOVENORMAL priority class
    BELOWNORMAL Start application in the BELOWNORMAL priority class
    WAIT        Start application and wait for it to terminate
    command/program
                If it is an internal cmd command or a batch file then
                the command processor is run with the /K switch to cmd.exe.
                This means that the window will remain after the command
                has been run.
```
Lines like "@ echo off" and "cls" don't really do anything that interesting.

Have tried to just remove the START? I believe it is because you have the START at the end of the line that you have opened a new process.
Since you then added the additional line of "cls" then that was enough to satisfy the need for the START, so then your last line of "exit" was able to close the window.

Again, since you are able to run your program without the leading START command, and the "@echo off" and "cls" don't really do anything, and finally the "exit" closes the window, my last question is why do you need the MS DOS window at all?
Why not just have a shortcut icon that runs "C:\E-Com\EC-Connect\ECConnectsched.exe" and be done with it?


----------



## jimi (Jun 14, 2000)

chucke what you posted sounds correct, the initial *.bat file i posted was sent to us by a vendor and i really didn't read it to notice the START cmd, but that be said i removed the start, echo off & cls commands and it still wouldn't close the window, so echo & cls are again in there. and why not just have a shortcut is because this program runs off a scheduled program that buried within our lousey pc based edi software.


----------



## ChuckE (Aug 30, 2004)

Couldn't you just set up an "at" schedule, to do a scheduled task?


----------



## ChuckE (Aug 30, 2004)

Ah wait! you said that this batch file runs off (from?) another scheduled program.
I think that program might be set up wrong to call the batch file.
I think might be what is hanging up your batch file.

If you really need this batch file then perhaps these lines might be better:
*C:\E-Com\EC-Connect\ECConnectsched.exe
exit /b*

The *exit /b* might force the current batch script to exit.
Perhaps instead a *exit /b 0* to pass a "0" errorlevel back to the calling program.
Just a guess.


----------

