Click to See Complete Forum and Search --> : more .bat file questions...
tablesalt
April 24th, 2001, 02:35 PM
Windows 9x will not close a DOS box that a batch command just ran in. Instead it is left open to be closed manually with a "finished" posted in the title bar. Is there anyway to get this to close on its own once its done? I thought the "exit" command might do this, but did not work. NT/2000 do not have this problem. :confused:
Darren Wilson
April 24th, 2001, 02:44 PM
Right click - Properties - check box that says Close on Finish or similar. Win2K hasn't got that option, but it should be available in 9x/ME
tablesalt
April 24th, 2001, 06:01 PM
I thought of that option, but the problem with it is, this batch file is being launched via hyperlink from a web page on an intranet. In this way there is no way to set such properties.
3fingersalute
April 25th, 2001, 07:20 AM
What if you put exit at the end of the batch file?...Also, there should be a pif file somewhere from the bat file that you can edit to close on exit!
Student^2
April 25th, 2001, 02:26 PM
Are you just trying to dig every bit of batch file knowledge I still retain out of my head? ;)
There was a command line paramater you passed that forced the window shut when the batch finished. I just don't remember it at the moment.... but I still have some books that list it, so I'll check on it tonight...
FooL
April 25th, 2001, 02:43 PM
I've learned .bat file little by litte. Mostly editing them and seeing what changes. But this is what I put in to make it go away. Anyone feel free to correct me if I'm wrong.
@ECHO OFF (at the beginning of the file.
***body of .bat file***
:END(at the end of the file.)
Student^2
April 25th, 2001, 03:43 PM
I thought that was it too, but the sample batch I gave to Compaqman included an :end statement. So I guess the question is did he use it or not?
Well, didja? :)
EDIT: err, well I thought it did, but I just went to look in that thread and I didn't put it in. If there isn't and END statement in there Compaqman, add it and that should do it!
Props to FooL, who isn't living down to his / her moniker.... :D
xt477
April 25th, 2001, 04:30 PM
if windows didnt, then you need to copy the pif file created by what Mr. Wilson said to do into the directory of the batch file.
right click/properties/program/close on exit created a pif in that directory for me
although I just did it locally, it did work using html and run from current location.
Will play on my lan at home tonite and let you know what happens
xt477
April 25th, 2001, 05:26 PM
ok I had to copy the pif file from my windows\pif directory but once I did this it works fine accross my peer to peer lan using html to link to the file.
tablesalt
April 25th, 2001, 06:14 PM
Unfortunately putting an :end at the end of the file did not work for me. I'm to the point where I just put in "echo Please close this window when completed." As far as the issue regarding the PIF file. This would typically work except for the fact that as I stated to Darren that the file is being launched from a hyperlink on a intranet page so does not reside on the local hard drive.
Higg
April 26th, 2001, 08:22 AM
Originally posted by Student^2:
There was a command line paramater you passed that forced the window shut when the batch finished. I just don't remember it at the moment
I agree with student... there must be a parameter I don't remember that works with this... perhaps it's a "COMPSPEC=something" line you need or a "COMMAND.EXE /whatever" that overrides the current command-instance and does the job.
In every case is the purpose of the ":END" thing only to have label for pseudo-structured programming... nothing more! You can simply point a "GOTO :END" to the end, but it does nothing else than to be a LABEL.
Hope that helps... Higg
antonye
April 26th, 2001, 10:34 AM
Umm, just a thought, but should you really be calling a batch file from a link on a webpage?
Letting users run batch files through the web server is quite a large security hole!
You could always write a bit of ASP script instead to call the functions you want.
Higg
April 26th, 2001, 10:51 AM
Originally posted by antonye:
Letting users run batch files through the web server is quite a large security hole!
I'd do the same, as I feel more comfortable with batches - even though I totally agree with you
Student^2
April 26th, 2001, 11:00 AM
Just found out that (under NT)
cmd.exe /c myfile.bat
will do exactly what you want. It opens a new instance of the command interpreter for running whatever, and closes ti when done. I don't have a 98 box handy, but maybe it will work with command as well?
Oberon42
May 7th, 2001, 06:33 AM
Is there a website that would show the parameters for a batch file?
I have found myself writing a bunch of them
lately and would like some guidance
Thanks for all the help
SubZero
May 7th, 2001, 08:42 AM
Here is a good reference:
Batfiles (http://home7.inet.tele.dk/batfiles/)
Higg
May 7th, 2001, 09:03 AM
I love to hang around on this page every time I need some Batch-Infos:
Rob van der Woude's scripting pages (http://www.robvanderwoude.com/)
ShadowWynd
May 9th, 2001, 01:07 PM
Try this:
at the command prompt, type:
ECHO HPS(ALT+203) > reboot.com
(the (ALT+203) is entered by holding ALT, then typing 203 on the numeric keypad, looks like the outline of a short "T"))
You should have 4 characters being piped to the file reboot.com
If run in pure DOS, this handy bit-o-code restarts the whole computer.... BUT, if in a Win9X DOS shell, it will terminate the shell.
So your batch file then looks something like:
@echo off
blah blah
yakkity schmakitty
....
reboot
apelsystems
May 11th, 2001, 09:22 PM
Do a search on www.askjeeves.com (http://www.askjeeves.com) and you should find everthing that you need.
Polychronopolis
May 14th, 2001, 03:04 PM
All other arguments aside, the answer is CLS. If you run a batch file from windows and it leaves you with the "Finished - autoexec.bat", a clear screen command at the end of the batch file will remove this screen.
REM Demo
ECHO This is a test.
CLS
--So says Polychronopolis..
SubZero
May 14th, 2001, 03:07 PM
Actually, that won't do it. That is what is displayed in the title bar in Windows.
Originally posted by Polychronopolis:
All other arguments aside, the answer is CLS. If you run a batch file from windows and it leaves you with the "Finished - autoexec.bat", a clear screen command at the end of the batch file will remove this screen.
REM Demo
ECHO This is a test.
CLS
--So says Polychronopolis..
Polychronopolis
May 14th, 2001, 03:21 PM
I'll promise you that CLS works in Win95. It is a tried and true method from batching installs of software. Though CLS is a Dos command to clear the screen, in a Dos window it will close the Finished window. I can't vouch for 98 and ME, but give it a try.
--So says Polychronopolis..
Polychronopolis
May 14th, 2001, 04:51 PM
Ok, now I went home and tested the CLS command in Win98SE and WinME. Both worked wonderfully for closing out the window.
The answer to the original question IS "Put CLS as the last line of your batch file to close the window it is running in."
--So Confidently Says Polychronopolis..
futuretech
May 20th, 2001, 02:07 AM
You could write a batch file to exit to windows and place a call in the previous one just before the end command.
condor
May 20th, 2001, 05:34 AM
in order to run an appliction or batch file and close the launch window just use the start command.
---------------------------------------------
C:\>start /?
Starts a separate window to run a specified program or command.
START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
[/WAIT] [/B] [command/program]
[parameters]
"title" Title to display in window title bar.
path Starting directory
B Start application without creating a new window. The
application has ^C handling ignored. Unless the application
enables ^C processing, ^Break is the only way to interrupt
the application
I The new environment will be the original environment passed
to the cmd.exe and not the current environment.
MIN Start window minimized
MAX Start window maximized
SEPARATE Start 16-bit Windows program in separate memory space
SHARED Start 16-bit Windows program in shared memory space
LOW Start application in the IDLE priority class
NORMAL Start application in the NORMAL priority class
HIGH Start application in the HIGH priority class
REALTIME Start application in the REALTIME priority class
ABOVENORMAL Start application in the ABOVENORMAL priority class
BELOWNORMAL Start application in the BELOWNORMAL priority class
WAIT Start application and wait for it to terminate
command/program
If it is an internal cmd command or a batch file then
the command processor is run with the /K switch to cmd.exe.
This means that the window will remain after the command
has been run.
If it is not an internal cmd command or batch file then
it is a program and will run as either a windowed application
or a console application.
parameters These are the parameters passed to the command/program
If Command Extensions are enabled, external command invocation
through the command line or the START command changes as follows:
non-executable files may be invoked through their file association just
by typing the name of the file as a command. (e.g. WORD.DOC would
launch the application associated with the .DOC file extension).
See the ASSOC and FTYPE commands for how to create these
associations from within a command script.
When executing an application that is a 32-bit GUI application, CMD.EXE
does not wait for the application to terminate before returning to
the command prompt. This new behavior does NOT occur if executing
within a command script.
When executing a command line whose first token is the string "CMD "
without an extension or path qualifier, then "CMD" is replaced with
the value of the COMSPEC variable. This prevents picking up CMD.EXE
from the current directory.
When executing a command line whose first token does NOT contain an
extension, then CMD.EXE uses the value of the PATHEXT
environment variable to determine which extensions to look for
and in what order. The default value for the PATHEXT variable
is:
.COM;.EXE;.BAT;.CMD
Notice the syntax is the same as the PATH variable, with
semicolons separating the different elements.
When searching for an executable, if there is no match on any extension,
then looks to see if the name matches a directory name. If it does, the
START command launches the Explorer on that path. If done from the
command line, it is the equivalent to doing a CD /D to that path.
---------------------------------------------
---------------------------------------------
if you're using a batch files use Call command to run another batch..
---------------------------------------------
C:\>call /?
Calls one batch program from another.
CALL [drive:][path]filename [batch-parameters]
batch-parameters Specifies any command-line information required by the
batch program.
If Command Extensions are enabled CALL changes as follows:
CALL command now accepts labels as the target of the CALL. The syntax
is:
CALL :label arguments
A new batch file context is created with the specified arguments and
control is passed to the statement after the label specified. You must
"exit" twice by reaching the end of the batch script file twice. The
first time you read the end, control will return to just after the CALL
statement. The second time will exit the batch script. Type GOTO /?
for a description of the GOTO :EOF extension that will allow you to
"return" from a batch script.
In addition, expansion of batch script argument references (%0, %1,
etc.) have been changed as follows:
%* in a batch script refers to all the arguments (e.g. %1 %2 %3
%4 %5 ...)
Substitution of batch parameters (%n) has been enhanced. You can
now use the following optional syntax:
%~1 - expands %1 removing any surrounding quotes (")
%~f1 - expands %1 to a fully qualified path name
%~d1 - expands %1 to a drive letter only
%~p1 - expands %1 to a path only
%~n1 - expands %1 to a file name only
%~x1 - expands %1 to a file extension only
%~s1 - expanded path contains short names only
%~a1 - expands %1 to file attributes
%~t1 - expands %1 to date/time of file
%~z1 - expands %1 to size of file
%~$PATH:1 - searches the directories listed in the PATH
environment variable and expands %1 to the fully
qualified name of the first one found. If the
environment variable name is not defined or the
file is not found by the search, then this
modifier expands to the empty string
The modifiers can be combined to get compound results:
%~dp1 - expands %1 to a drive letter and path only
%~nx1 - expands %1 to a file name and extension only
%~dp$PATH:1 - searches the directories listed in the PATH
environment variable for %1 and expands to the
drive letter and path of the first one found.
%~ftza1 - expands %1 to a DIR like output line
In the above examples %1 and PATH can be replaced by other
valid values. The %~ syntax is terminated by a valid argument
number. The %~ modifiers may not be used with %*
--------------------------------------------
--------------------------------------------
Hope it helps
Mr_Miyagi
May 20th, 2001, 08:30 AM
cripes, condor, is that an answer or is that an answer..!!!
;)
JungleMan1
May 20th, 2001, 11:02 AM
Originally posted by Mr Myagi:
cripes, condor, is that an answer or is that an answer..!!!
;)
I'm pretty sure that was an answer!
Great Condor, seems you still know your DOS commands, I forgot all mine heheh. But at least I know it's more than a "stupid black screen" ROFLMAO :D :D ;) ;)
tablesalt
May 20th, 2001, 04:42 PM
Well, first time I've returned to this post since I first placed it several weeks ago! Looks like I'm not the only one who still uses batch files for automated installs and what not! Condor, thanks for the huge batch 'o info!
goodespeler
May 20th, 2001, 08:49 PM
Here is a site with batch file paremeters <a href="http://www.cit.ac.nz/smac/msdos/msdos18.htm">http://www.cit.ac.nz/smac/msdos/msdos18.htm</a>
goodespeler
May 20th, 2001, 08:50 PM
Here is a site with batch file paremeters
<a href="http://www.cit.ac.nz/smac/msdos/msdos18.htm">http://www.cit.ac.nz/smac/msdos/msdos18.htm</a>
<marquee>Good Luck!!</marquee>
goodespeler
May 20th, 2001, 08:51 PM
Try here for parameter http://www.cit.ac.nz/smac/msdos/msdos18.htm
<marquee>Good Luck!!</marquee>