Need Batch File to Exit After Running

I need a batch file to close after running.  Every time I've found a way to get the file to close after doing its job, it fails to launch the program specified.  If I get the file to launch the program specified, it will not close.  As listed below, the file will launch the program, but will not close the batch window.  If i remove the live launching HTTPSyncStat, the window will exit just fine.  I have not played with batch files in quite some time.  Help!



tskill httpsyncstat /A
tskill httpxpt /A
tskill msync /A

@echo off
   echo Pausing for 5 seconds...
   call :pause 5
   "c:\Program Files\CDC Software\Pivotal CRM\SyncStream\httpsyncstat.exe"
   exit /b

:pause
setlocal
set t1=%time%
set t1=%t1::=%
set t1=%t1:~0,6%
set t1=0%t1: =%
set t1=%t1:~-6%
set /a t1=%t1%+%1

:loop
   set t2=%time%
   set t2=%t2::=%
   set t2=%t2:~0,6%
   set t2=0%t2: =%
   set t2=%t2:~-6%
if %t2% LSS %t1% goto :loop

endlocal
exit /b

Open in new window

CPUAffinityAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

giltjrCommented:
Try changing":

   "c:\Program Files\CDC Software\Pivotal CRM\SyncStream\httpsyncstat.exe"


to

     start    "c:\Program Files\CDC Software\Pivotal CRM\SyncStream\httpsyncstat.exe"
0
Bill PrewIT / Software Engineering ConsultantCommented:
In the main routine, just before the exit /b, why not add a pause to give the EXE a chance to launch, maybe another 5 seconds.  Then change the exit /b to just an exit.

~bp
0
Bill PrewIT / Software Engineering ConsultantCommented:
Ah yes, START will be needed, doh.  

Without the START the batch file will wait for the EXE to finish before it continues.  With the START it will launch the EXE, and then continue running.  At that point the exit /b should close it out just fine.

~bp
0
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

GPruettCommented:
If you use the "start" command to launch the program on line 8, it will launch that program in a separate window.  If you wish to run that program in the same window as the original batch program, use "start /B".
0
Steve KnightIT ConsultancyCommented:
Comment #1 is nearly right.  You will need to use an extra parameter as there are quotes around the filename:
START "Window title" "c:\Program Files\CDC Software\Pivotal CRM\SyncStream\httpsyncstat.exe"

or just

START "" "c:\Program Files\CDC Software\Pivotal CRM\SyncStream\httpsyncstat.exe"

Steve
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve KnightIT ConsultancyCommented:
As the first parameter in quotes is seen as the window title... nice gotcha with START!
0
CPUAffinityAuthor Commented:
With START added, the window does close, but just before it closes it launches another CMD window with the program path in the title bar, but the program does not launch & this window remains open at the C:\Documents and Settings\profile_name_here\Desktop>

Adding the additional pause yields the initial result.
0
Bill PrewIT / Software Engineering ConsultantCommented:
Another good point on the START quirky syntax, I remember getting bit by that and not believing it at the time.

FWIW, a simpler way to delay fo 5 seconds would be:

PING -n 1 -w 5000 1.1.1.1>NUL

This uses the PING command to attempt to ping a nonexistant IP, and waits for 5 seconds to timeout.

~bp
0
giltjrCommented:
dragon-it.  thanks for catching that.  I forgot about the title part.
0
Steve KnightIT ConsultancyCommented:
CPUAffinity: that is the extra issue I suggested then.  Please try what I posted above and should be good to go hopefully.

Steve
0
CPUAffinityAuthor Commented:
That did the trick, Thanks!
0
Steve KnightIT ConsultancyCommented:
No problem, sorry for jumping in there everyone ;-)
0
giltjrCommented:
Actually there is a sleep command that MS provides in their server tool kits:

     http://www.microsoft.com/downloads/details.aspx?FamilyID=9D467A69-57FF-4AE7-96EE-B18C4790CFFD&displaylang=en

It is a little better than the ping trick, but if you don't want to get sleep then the ping trick is the way to go.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.