Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Closing apps opened with the START command...

318 views
Skip to first unread message

KILOWATT

unread,
Apr 20, 2005, 9:04:27 PM4/20/05
to
Hi everyones...thanks to read.
I know how to open some files within a batch file by using the START command
in it.Now is there's any other command available to use to close the opened
file? TIA

--
Alain(alias:Kilowatt)
Montréal Québec
PS: 1000 excuses for grammatical errors or
omissions, i'm a "pure" french canadian! :-)
Come to visit me at: http://kilowatt.camarades.com
(If replying also by e-mail, remove
"no spam" from the adress.)


William Allen

unread,
Apr 21, 2005, 1:57:23 AM4/21/05
to
"KILOWATT" wrote in message

> Hi everyones...thanks to read.
> I know how to open some files within a batch file by using the START command
> in it.Now is there's any other command available to use to close the opened
> file? TIA

Ensure your Batch file starts with:

@ECHO OFF

and ensure that the last instructions are:

CLS
EXIT

Then, the Batch window should close automatically when
the Batch file finishes. For more details see:
Batch file troubleshooting: http://www.allenware.com/find?UsualSuspects

Look at the second item in the troubleshooter table:
MS-DOS window doesn't close (or closes too soon)

--
William Allen
Free interactive Batch Course http://www.allenware.com/icsw/icswidx.htm
Batch Reference with examples http://www.allenware.com/icsw/icswref.htm
Header email is rarely checked. Contact us at http://www.allenware.com/


David Trimboli

unread,
Apr 21, 2005, 9:47:05 AM4/21/05
to
William Allen wrote:
> "KILOWATT" wrote in message
>
>>Hi everyones...thanks to read.
>>I know how to open some files within a batch file by using the START command
>>in it.Now is there's any other command available to use to close the opened
>>file? TIA
>
>
> Ensure your Batch file starts with:
>
> @ECHO OFF
>
> and ensure that the last instructions are:
>
> CLS
> EXIT
>
> Then, the Batch window should close automatically when
> the Batch file finishes. For more details see:
> Batch file troubleshooting: http://www.allenware.com/find?UsualSuspects
>
> Look at the second item in the troubleshooter table:
> MS-DOS window doesn't close (or closes too soon)

I don't think that's what the original poster meant. He meant if you
open, say, a text file in Notepad using a batch file and the Start
command, how can you close it again in the same batch file?

There is no command that will do this. You might shut off the particular
process (for instance, notepad.exe), but this will shut off any open
files under that process, not just the one Started.

I'm sure there are third-party programs that will do this.

David
Stardate 5304.7

Todd Vargo

unread,
Apr 21, 2005, 10:33:25 AM4/21/05
to

"David Trimboli" wrote:
> > "KILOWATT" wrote in message
> >
> >>I know how to open some files within a batch file by using the START
> >>command in it.Now is there's any other command available to use to
> >>close the opened file? TIA

> There is no command that will do this. You might shut off the particular


> process (for instance, notepad.exe), but this will shut off any open
> files under that process, not just the one Started.
>
> I'm sure there are third-party programs that will do this.

Process Viewer for Windows NT and 95-98
http://www.teamcti.com/pview/prcview.htm

Instead of using START, another method OP could use to launch a file is by
using WSH to trap the exact PID, store it to be used later for closing the
file. With a better description of what the OP is doing, I would be inclined
to elucidate with an example.

--
Todd Vargo (double "L" to reply by email)

William Allen

unread,
Apr 21, 2005, 12:29:06 PM4/21/05
to
"David Trimboli" wrote in message

Many Windows applications close with [Alt]-[F4], and when this
command is issued, they usually prompt for Y/N to save any
open altered file. So the SendKeys function of WSH can be
used to issue this command combo assuming the file opened
is still the window with focus. The only question remaining is
when, or on what event, to issue the window close and save
any changed file command.

This example opens NotePad and closes it again after 10
seconds, saving any changes to the opened file, as long
as the opened file is still the window with focus.

Lines that don't begin with two spaces have wrapped accidentally
====Begin cut-and-paste (omit this line)
@ECHO OFF

ECHO. Create a file>FILE.TXT

start Notepad FILE.TXT

ping -n 11 127.0.0.1 >NUL

ECHO.set sh=WScript.CreateObject("WScript.Shell")>_TEMP.VBS
ECHO.sh.SendKeys("%%{F4}Y")>>_TEMP.VBS
cscript//nologo _TEMP.VBS
DEL _TEMP.VBS

====End cut-and-paste (omit this line)
For Win95/98/ME study/demo use. Cut-and-paste as plain-text Batch file.

Only the OP knows what they want.

KILOWATT

unread,
Apr 21, 2005, 3:33:28 PM4/21/05
to
Thanks to all for your present (and future replies). As David said, the
problem is not to close the dos window when the batch file ends. batch
file's properties>program tab>ticking the "close on exit box">clicking OK
addresses this. The problem is effectively to close an application opened by
the batch file itself. Here's the application i need it for:
I want to be notified by a visual and audio event a few minutes before an
Ebay auction is ending so i don't miss the chance to bid during the critical
remaining time. I already have a text file named ebay_notify.txt in wich the
message "An Ebay item i'm watching is ending in a few minutes!" and a wav
file named alarm.wav wich opens in Winamp player. Those files are in the
same directory than the batch file. The batch file itself is called at a
predetermined time by using the Windows Task Scheduler. Here's the actual
(and simple!) batch file's content:

start ebay_notify.txt
start alarm.wav.txt

What i would like is to add a pause to it, then commands to close those
notepad and winamp instances. Since the wav duration is about 5 seconds...
a 7~10 seconds pause before the batch closes those tasks would be
great...hmm... required! ;-) TIA for your replies.


KILOWATT

unread,
Apr 21, 2005, 3:35:24 PM4/21/05
to
Oups...sorry for the mistyping. The batch file is actually:
start ebay_notify.txt
start alarm.wav

NOT

start ebay_notify.txt
start alarm.wav.txt

:-)


William Allen

unread,
Apr 21, 2005, 5:23:16 PM4/21/05
to
"KILOWATT" wrote in message

Popping up NotePad seems a kludgey way to display an alert. And
I've never used Winamp, so I don't know the command line switches.

However, standard Windows functions can do what you want.

The standard MPLAYER.EXE can play WAVs and accepts the
-play switch to start play automatically, and the -close switch
to end play when the WAV finishes.

WSH provides a message box alert function with a timeout
to cancel the box.

This demo should play the sound in your MPLAYER.EXE (use
MPLAYER2.EXE or similar if that's what you have) and throw
up a message box alert with a big red cross for ten seconds.
Alter the obvious strings for the Message Box message and
the Window title. Click the OK box on the Message Box to
close it before the 10 seconds are up. Change the value
in the //T:nn switch of CSCRIPT to alter the 10 seconds time.

Lines that don't begin with two spaces have wrapped accidentally
====Begin cut-and-paste (omit this line)
@ECHO OFF

start mplayer.exe -play -close YourSound.wav
ECHO/Ret=MsgBox ("Time to waste time on Ebay!", 16, "Wake up")>_TEMP.VBS
:: Display the Message Box for 10 seconds
cscript//nologo //T:10 _TEMP.VBS>NUL
DEL _TEMP.VBS

====End cut-and-paste (omit this line)
For Win95/98/ME study/demo use. Cut-and-paste as plain-text Batch file.
Batch file troubleshooting: http://www.allenware.com/find?UsualSuspects

--

Todd Vargo

unread,
Apr 21, 2005, 6:28:54 PM4/21/05
to

"William Allen" wrote:
> This demo should play the sound in your MPLAYER.EXE (use
> MPLAYER2.EXE or similar if that's what you have) and throw
> up a message box alert with a big red cross for ten seconds.
> Alter the obvious strings for the Message Box message and
> the Window title. Click the OK box on the Message Box to
> close it before the 10 seconds are up. Change the value
> in the //T:nn switch of CSCRIPT to alter the 10 seconds time.
>
> Lines that don't begin with two spaces have wrapped accidentally
> ====Begin cut-and-paste (omit this line)
> @ECHO OFF
> start mplayer.exe -play -close YourSound.wav
> ECHO/Ret=MsgBox ("Time to waste time on Ebay!", 16, "Wake up")>_TEMP.VBS
> :: Display the Message Box for 10 seconds
> cscript//nologo //T:10 _TEMP.VBS>NUL
> DEL _TEMP.VBS
>
> ====End cut-and-paste (omit this line)

IMO, sndrec32.exe loads more efficiently than mplayer.exe and it should be
opened as minimized for a clean display, YMMV.

start /min sndrec32.exe -play -close YourSound.wav

Mark V

unread,
Apr 21, 2005, 10:06:36 PM4/21/05
to
In alt.msdos.batch.nt KILOWATT wrote:

3rd party tools?

START "" <path>\wav.exe <path>\WAVfile.wav
START "" <path>\msgbox.exe "message text" "title" 1 1

But you would be left to click "OK" in the raised message box.

WAV.EXE v2.65 - Command line audio file player
Copyright (c) 1998-2001 by WebGeek, Inc.

MsgBox 2.0 - Batch file messagebox utility by Doug Good
Freeware copyright 2002 Outside The Box Software
(http://www.otbsw.com)
[that URL may be bad]

Just a thought.

William Allen

unread,
Apr 22, 2005, 12:43:31 AM4/22/05
to
"Todd Vargo" wrote in message
...snip

> IMO, sndrec32.exe loads more efficiently than mplayer.exe and it should be
> opened as minimized for a clean display, YMMV.
>
> start /min sndrec32.exe -play -close YourSound.wav

Yes, better, and works fine here, too.

--
William Allen


KILOWATT

unread,
Apr 23, 2005, 2:24:17 AM4/23/05
to
Hi again everyones. I wish to really thank you all for your time and
helpfulness, William, David , Todd, and Mark! Here's what i've choosen to
meet my needs:

start EBAY.VBS
start /min sndrec32.exe -play -close chime.wav

The .VBS file itself contains the following: (thanks again William for the
inspiration! ;-))
Ret=MsgBox ("An Ebay item i'm watching is ending soon!", 16, "Wake up")


The idea of a pop-up text window was 1st interesting...and was (and still!)
impressed also with your script William. I've experimented with it and also
discoved that different type of pop-up boxes could be choosen by changing
the number 16 to something else. I didn't knew that mplayer.exe and
sndrec32.exe had those useful switches...NICE! I know that 1st i wanted that
the visual text notification had to disappear after X seconds, but finally
i've decided that it wasn't a good idea because if i happened to miss the
sound notification for any reason ( unaware that the speakers were muted...i
was outside...etc), i would also miss the text notification. So i decided
that the text should stay after the sound files exits, so i will see it and
then close myself the text notification. The command line you provided for
the sound file, coupled with the task scheduler, can make a nice clock alarm
without installing any software...and also you won't need with this one to
press the "snooze" button we loves so much each morning! ;-) Scripting can
do a lot to automate simple things, and you guys were really helpful. Thanks
again.

William Allen

unread,
Apr 23, 2005, 3:07:04 AM4/23/05
to
"KILOWATT" wrote in message
...snip

>Here's what i've choosen to
> meet my needs:
>
> start EBAY.VBS
> start /min sndrec32.exe -play -close chime.wav

Todd's sndrec32 suggestion was a good one to use.

> The .VBS file itself contains the following: (thanks again William for the
> inspiration! ;-))
> Ret=MsgBox ("An Ebay item i'm watching is ending soon!", 16, "Wake up")
>
>
> The idea of a pop-up text window was 1st interesting...and was (and still!)
> impressed also with your script William. I've experimented with it and also
> discoved that different type of pop-up boxes could be choosen by changing
> the number 16 to something else.

I chose 16 because it gives a big red cross (critical error message).
You build up the number in that field by adding together powers of two,
or using the built-in VBS constant names. This is the table of what
you can use for that number and what it does. Read in fixed width font:

(Quoted from WSH standard help file)
The following constants are used with the MsgBox function to
identify what buttons and icons appear on a message box and
which button is the default. In addition, the modality of the
MsgBox can be specified. Since these constants are built into
VBScript, you don't have to define them before using them.
Use them anywhere in your code to represent the values shown
for each.

Constant Value Description
vbOKOnly 0 Display OK button only.
vbOKCancel 1 Display OK and Cancel buttons.
vbAbortRetryIgnore 2 Display Abort, Retry, and Ignore buttons.
vbYesNoCancel 3 Display Yes, No, and Cancel buttons.
vbYesNo 4 Display Yes and No buttons.
vbRetryCancel 5 Display Retry and Cancel buttons.
vbCritical 16 Display Critical Message icon.
vbQuestion 32 Display Warning Query icon.
vbExclamation 48 Display Warning Message icon.
vbInformation 64 Display Information Message icon.
vbDefaultButton1 0 First button is the default.
vbDefaultButton2 256 Second button is the default.
vbDefaultButton3 512 Third button is the default.
vbDefaultButton4 768 Fourth button is the default.
vbApplicationModal 0 Application modal. The user must
respond to the message box before
continuing work in current application.
vbSystemModal 4096 System modal. On Win16 systems,
all applications are suspended
until the user responds to the
message box. On Win32 systems,
this constant provides an
application modal message box
that always remains on top of
any other programs you may have
running.

So, for example, 65 = 64 + 1 would
64=Display Information Message icon.
and also
1=Display OK and Cancel buttons.

Get the WSH standard help files from:
http://msdn.microsoft.com/scripting/

Mike Jones

unread,
Apr 23, 2005, 5:19:49 AM4/23/05
to
KILOWATT" <kilowatt"nospam wrote:
> Hi again everyones. I wish to really thank you all for your time and
> helpfulness, William, David , Todd, and Mark! Here's what i've
> choosen to meet my needs:
>
> start EBAY.VBS
> start /min sndrec32.exe -play -close chime.wav
>
> The .VBS file itself contains the following: (thanks again William
> for the inspiration! ;-))
> Ret=MsgBox ("An Ebay item i'm watching is ending soon!", 16, "Wake
> up")
>
Why not also/instead open up a new browser window on ebay whilst you're at
it?
(just cut and paste the url into your reminder program)


daniel brower

unread,
Apr 23, 2005, 9:59:31 AM4/23/05
to
lol, couldn't be happier for you but i have a suggestion
albeit not a script or batch solution, but a differnt one

ebay will email you when an auction is about to end and you
didn't win the bid, leave your outlook express up and running
and tell it to make a sound when you have new mail.

then turn your computer speaker WAY up lol


"KILOWATT" <kilowatt"nospam"@softhome.net> wrote in message
news:kSlae.26005$Jg5.1...@news20.bellglobal.com...

Si Ballenger

unread,
Apr 23, 2005, 10:55:40 AM4/23/05
to

If it is a really important item you've just got to have, you
might try the below:

@echo off
start ebay.vbs
:loop
start /min sndrec32.exe /play /close %windir%\media\ringin.wav
ping -n 6 127.0.0.1 > nul
goto :loop

0 new messages