Hi,
I am new to dos and can only grasp simple instructions at the moment.
I would like to open 2 files in the same directory. File 1 to be opened first and then File 2 five seconds afterwards.
My main problem is that I would like file 1 to automatically close when I close file 2. Is this something that can do in dos or does it require some kind of programming skills
Apologies for the noob question.
Help for Dos Newbie - Open 2 files and specfic close option
Moderator: DosItHelp
Re: Help for Dos Newbie - Open 2 files and specfic close opt
'
What do u mean by opening a file ?, Locking it from being written to ?
This can be done with vbscript. Nothing like that with default DOS commands
What do u mean by opening a file ?, Locking it from being written to ?
This can be done with vbscript. Nothing like that with default DOS commands

Re: Help for Dos Newbie - Open 2 files and specfic close opt
Hi,
Not really. Heres the timing batch which I worked out for myself. Delay of 10 seconds between opening first.exe and second.exe. What I need to know is when I close second.exe can I have a script that closes first.exe as well?
It's probably not possible with any Dos commands like you said.
@ECHO OFF
start first.exe
echo wscript.sleep 10000 > temp.vbs
start /wait temp.vbs
start second.exe
del temp.vbs
Not really. Heres the timing batch which I worked out for myself. Delay of 10 seconds between opening first.exe and second.exe. What I need to know is when I close second.exe can I have a script that closes first.exe as well?
It's probably not possible with any Dos commands like you said.
@ECHO OFF
start first.exe
echo wscript.sleep 10000 > temp.vbs
start /wait temp.vbs
start second.exe
del temp.vbs
Re: Help for Dos Newbie - Open 2 files and specfic close opt
Hi,
I tried adding this to the batch and it didn't quit the first file when I quit the second. Maybe my explanation is poor?
If it can't be done then is it possible to minimise the first file to the toolbar?
Thanks
Chris
I tried adding this to the batch and it didn't quit the first file when I quit the second. Maybe my explanation is poor?
If it can't be done then is it possible to minimise the first file to the toolbar?
Thanks
Chris
Re: Help for Dos Newbie - Open 2 files and specfic close opt
'
Shutting down a process is not too difficult:
Shutting down a process is not too difficult:
Code: Select all
@echo off
taskKill.EXE /?
pause
taskKill.EXE /t /f /im "cmd.EXE"
echo.never get's here.
pause
exit /b 0
Re: Help for Dos Newbie - Open 2 files and specfic close opt
Here it is. The file stars from the line @echo off
It opens calc.exe(process 1) and wordpad.exe(process 2)
If you then close calc.exe, wordpad.exe will immediately close.
The way it works, is it starts them both.
Then in a loop it keeps testing if calc.exe is running. If it isn't running, then it has been closed, then it closes wordpad.exe
You can put your vbscript 5 second pause between starting the two processes if you want.
@echo off
set tmpf=%TEMP%\asdf.a
set proc1=c:\windows\system32\calc.exe
set proc1b=calc.exe
set proc2="c:\Program Files\Windows NT\Accessories\wordpad.exe"
set proc2b=wordpad.exe
start "" %proc1%
start "" %proc2%
:BLAH
tasklist >"%tmpf%"
type "%tmpf%" | find "%proc1b%" >nul
if ERRORLEVEL 1 (
taskkill /f /im %proc2b% >nul
GOTO EOF
)
GOTO BLAH
:EOF
It opens calc.exe(process 1) and wordpad.exe(process 2)
If you then close calc.exe, wordpad.exe will immediately close.
The way it works, is it starts them both.
Then in a loop it keeps testing if calc.exe is running. If it isn't running, then it has been closed, then it closes wordpad.exe
You can put your vbscript 5 second pause between starting the two processes if you want.
@echo off
set tmpf=%TEMP%\asdf.a
set proc1=c:\windows\system32\calc.exe
set proc1b=calc.exe
set proc2="c:\Program Files\Windows NT\Accessories\wordpad.exe"
set proc2b=wordpad.exe
start "" %proc1%
start "" %proc2%
:BLAH
tasklist >"%tmpf%"
type "%tmpf%" | find "%proc1b%" >nul
if ERRORLEVEL 1 (
taskkill /f /im %proc2b% >nul
GOTO EOF
)
GOTO BLAH
:EOF
Re: Help for Dos Newbie - Open 2 files and specfic close opt
Thank very much worked a treat.