batch help???

  • Thread starter Thread starter nathan
  • Start date Start date
N

nathan

lets say i have a batch file(blah.bat) that looks like
this:

@echo off
cd /d "c:\batch files"
start blah.bat
cd..
dir /s
cls
exit

and blah1.bat looks like this:

@echo off
cls
for /l %%i in (1,1,12) do echo.
echo please wait...
:loop
goto loop

my question is how can i get blah1.bat to close when
blah.bat is finished running. is this possible? or is
there a better way to go about this? thanks
 
nathan said:
lets say i have a batch file(blah.bat) that looks like
this:
my question is how can i get blah1.bat to close when blah.bat is
finished running. is this possible? or is there a better way to go
about this? thanks

Your code doesn't make any sense to me. If the general idea is to synch
2 batches for whatever reason (this is *not* a home/course work isn't it)
you might use a "semaphore" file and check if it still exists.

Another way is to use a tasklist/pslist to check if the other batch is
still alive. http://www.sysinternals.com/ntw2k/freeware/pslist.shtml
 
-----Original Message-----



Your code doesn't make any sense to me. If the general idea is to synch
2 batches for whatever reason (this is *not* a home/course work isn't it)
you might use a "semaphore" file and check if it still exists.

Another way is to use a tasklist/pslist to check if the other batch is
still alive. http://www.sysinternals.com/ntw2k/freeware/pslist.shtml

--
Greetings
Matthias________________________________________
For help on nt commands enter in a cmd window:
W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm
.
the idea is to have blah1.bat to popup in front of
blah.bat while blah.bat is still running and when
blah.bat is finished, close blah1.bat. not sure how to do
this since blah1.bat is in a loop.... how can i break it
and get it to close?
 
.
blah.bat while blah.bat is still running and when
blah.bat is finished, close blah1.bat. not sure how to do
this since blah1.bat is in a loop.... how can i break it
and get it to close?

Assuming you don't want to hide a visible dir listing, it
might be a good idea to say what you reall want to do.

There might be a different and more elegant solution.

The semaphore I mentioned could simply be a zero btye
length file you create in the first batch at the begin
and delete after the job is done. The second batch
can check for this file

::batch1.bat
set Sema=%TEMP%\~%RANDOM%%RANDOM%.sem
echo.>"%Sema%"
start "" "%comspec%" /C ("C:\batch files\batch2.bat" "%Sema%")
dir /s/b
del /Q "%Sema%" >NUL
exit

::batch2.bat
@echo off
:loop
:: to have a small delay
echo please wait...
ping -n 2 localhost >NUL
if exist %1 goto :loop

HTH
 
Back
Top