--
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.)
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/
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
> 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)
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.
Batch file troubleshooting: http://www.allenware.com/find?UsualSuspects
Only the OP knows what they want.
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.
NOT
start ebay_notify.txt
start alarm.wav.txt
:-)
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
--
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
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.
Yes, better, and works fine here, too.
--
William Allen
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.
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/
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...
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