I give up! Does any kind soul want to help me with a batch file??

Ronstang

Lifer
Jul 8, 2000
12,493
18
81
I haven't written a DOS batch file in so many years that I have totally forgotten all the different commands and I can't find my old DOS book. I need a real simple batch file with a two choice menu that will execute one of two other batch files that I know already work. I'm using XP and all the examples of simple menu batch files I can find on the web will not work for some reason. I simply want to be able to choose whether shutdown.exe turns off or reboots my server. This should be simple but I don't remember enough to get it to work. Are there some of the older commands that don't work in XP's DOS emulator?

If anyone has the knowledge and a few minutes I would appreciate the help, it's hell getting old!

Thanks
 

AndyHui

Administrator Emeritus<br>Elite Member<br>AT FAQ M
Oct 9, 1999
13,141
17
81
A DOS command like Reboot is not going to work because it asks for direct access to the hardware. The emulated command prompt does not allow any program direct hardware access.

If you are using the classic interface in XP, I could probably come up with a Windows Script batch file for you, but I haven't tried it with Luna.
 

Ronstang

Lifer
Jul 8, 2000
12,493
18
81
Actually I am not using the reboot comand in DOS, I am using the shutdown.exe file specifically for XP. I have two batch files that run this command with the appropriate switches to accomplish my goal and I just want another batch file that is a menu that allows me to choose which one to run. It should be simple if someone knows the right commands because I do not.
 

btvillarin

Senior member
Nov 3, 2001
469
0
0
Well, I don't have a server. But, this page directed me to a shutdown.exe file and it's commands that can actually turn off your computer directly, and not just leave it hanging at the "You may now turn off this computer" screen. I wonder if this was what you were looking for.
http://www.aumha.org/a/shtrstrt.htm
 

jmatt

Member
Jul 9, 2001
125
0
0
Here is my file on Batch . John .

http://content.techweb.com/winmag/columns/explorer/2000/21.htm

htmhttp://download.mycomputer.com/detail/18/3.html
BatchRun

http://www.freetune.com/most_popular_pages.htm

http://www.simtel.net/cgi-bin/htsearch
http://www.simtel.net/pub/msdos/batchutl/

-------------------------------------------------

http://www.sover.net/~whoi/WinUtils1.html

Append A - command line utility that is great for batch files.
Append.exe will copy files just like the ms-dos copy command
does unless it finds the same filename in the destination directory.
When it finds the same name already present, it writes the source
file on to the end of the destination file, thereby keeping the data
already there and adding the new data. This is great for text log
files, reports, scripts, or any other file where you want to keep
what you already have and add on the end of it, rather than delete
before copy like ms-dos copy does. Append.exe also has an option to
delete the source file after it has been successfully copied.

--------------------------------------

http://download.mycomputer.com/detail/18/3.html

BatchRun - Lets you start several Windows programs or files
simultaneously. You could always use a DOS batch file for this,
but BatchRun's scripts run much faster. Specify whether programs
should start maximized or minimized, and configure delays between
application launches. BatchRun's attractive interface makes it a
breeze to create scripts. Internal commands include Copy, Rename,
Make-dir, and Delete. The BatchRun script extension (.brs) is
registered so that you can launch scripts from Explorer just by
double-clicking them.

---------------------------------

http://www.bookcase.com/library/software/msdos.util.dir.html

Does anyone know if there is a DOS command line which will delete all
files ending with a specific extension (eg .tmp) in the whole of
the c drive, including sub-folders?
I want to leave all folders and other files intact .

sst_53a.zip. This is Supersonic Search Tool by Keith Ledbetter. With
the -v switch it will delete a file globally.

---------------------------------

http://xset.tripod.com/index.html
Batch file tips , http://xset.tripod.com/batchtip.htm

XSET major features
Catch the output of any command (internal or external) or program and put it into an environment variable
Manages variable contents of more than 128 characters (your path can now be as long as you want)
Built-in commands to modify the output of a program or a string given on the command-line (extract a part of a string, ...)
Built-in full floating-point calculation functionality: You can program incremental loops, input a calculation string and output the resulting number, ...
Built-in commands to give you access to a lot of system data (date, time, file attributes, CPU type,...)
Built-in commands to clear the whole environment or restore a previously saved one
High-level input/output user interface (line-editing, colors, windows, boxes, ...)

Everything you always wanted to put in an environment variable but
were afraid to ask DOS, NT or OS/2 for . . .

XSET: The easy way to write efficient batch files.

XSET allows you to put EVERYTHING you want in a variable of the
current environment and use it as if you had assigned it the value with
the standard DOS command 'SET'. You will be able to write very efficient
batch files including string manipulation, calculation, ...

XSET is the most powerful environment variable manipulation program
you have ever seen. It also has a very easy and intuitive user interface
(very close to the 'SET' command). It is not a resident program; so it
will not interfere with any of your other applications.

XSET is fully compatible with MS-DOS (from 3.30), DR-DOS, NDOS, 4DOS,
OS/2, Windows 95/98 and Windows NT.


XSET has seven major features:

- XSET permits you to catch the output of any command (internal or
external) or program and put it into an environment variable.

- XSET has built-in commands to modify the output of a program or a
string given on the command-line (extract a part of a string, ...)

- XSET has a built-in full floating-point calculation functionality:
You can program incremental loops, input a calculation string and
output the resulting number, ...

- XSET can manage variable contents of more than 128 characters (your
path can now be as long as you want).

- XSET has other built-in commands to give you access to some system
data (date, time, ...)

- XSET has built-in commands to clear the whole environment or restore
a previously saved one.

- XSET gives you access to high-level input/output user interface
(line-editing, colors, windows, boxes, ...).


More than sixty commands to do all that you need.

--------------------------------

http://autofiles.hypermart.net
What is Auto Files?

Auto Files allows you to automate a variety of tasks on your computer.
It runs from your system tray and provides the graphical equivalent of
a batch programming language to define the details of jobs you want to
automate. A point-and-click, wizard-style interface allows you to choose
from a wide range of actions. These actions, which are all handled
internally by Auto Files, include FTP, email, zipped backups, printing,
message display, window manipulation, and send keys. Of course, you can
also select external programs to run. Events can be scheduled with a timer,
launched with a hotkey, or set to run when specific system changes trigger
the event. Other features include logging support and the ability to define
custom variables. Auto Files is capable, easy to use, and includes a number
of examples to help get you started.

-----------------------------

http://www.nc5.infi.net/~wtnewton/batch/

------------------------------

http://www.zdnet.com/pcmag/pctech/content/solutions/uu1717a.htm

http://www.cableyorkton.com/users/gbraun/batch/#whatfor
http://chkpt.zdnet.com/chkpt/xlink1...in/texis/swlib/hotfiles/info.html?fcode=56561
http://www.cableyorkton.com/users/gbraun/batch/batches.htm

http://www.nc5.infi.net/~wtnewton/batch/batchfaq.html#1

http://www.xs4all.nl/~wstudios/

http://www.nc5.infi.net/~wtnewton/batch/batchfaq.html#20

http://www.robvanderwoude.com/

http://www.robvanderwoude.com/batutils.html

http://www.robvanderwoude.com/books.html

http://www.oit.gatech.edu/software_exchange/UTILITIES95.html

Fire up Notepad or any text editor, write your batch, then
save it with a .bat extension - with Notepad select all files
when saving so notepad doesn't tack .txt on the end, or rename
it after saving. Note for Win95 - in Windows Explorer go to
View, Options, make sure hide extensions isn't checked. To run
your batch enter its name from a dos prompt or double-click
it from Windows. Learn some dos first! Be careful since batch
misapplied can reduce your computer to an expensive paperweight
until you reload whatever you wiped out...

To get your batch to run from any directory, put the batch
in a path directory.. enter PATH at a dos prompt for a list.
Modify autoexec.bat to set up your own batch path directory,
for example: PATH C:\windows;C:\Windows\command;C:\batch


*** Where can I get batch information?

The best reference is probably the dos help files, if entering
HELP does nothing look on your Win95 CD in other\oldmsdos. Also
available at Microsoft's web site. It doesn't cover Win95 but
there really isn't much difference.

Batch information on the web...

http://www.maem.umr.edu/~batch/ - Ted Davis' page
http://www.pressroom.com/~tglbatch/ - Tom Lavedas' page
http://www.calweb.com/~webspace/batch/ - Eric's page
http://www.nc5.infi.net/~wtnewton/batch/ - Terry's page
http://purl.oclc.org/net/dirk/batcoll.all - Dirk's bat techniques
http://bigfoot.com/~batfiles/ - Laurence Soucy's page
http://www.computerhope.com/msdos.htm
http://www.computerhope.com/issues/ch000435.htm
http://malektips.envprogramming.com/windows_98_and_dostoc.html

http://www.techtutorials.com/DOS/Batch_Files_and_Programming/
http://www.cs.ntu.edu.au/homepages/bea/home/subjects/ith305/ith305.html
http://www.cs.ntu.edu.au/homepages/bea/home/subjects/ith305/lect1.html

http://malektips.envprogramming.com/dos_helptoc.html


http://www.computerhope.com/batch.htm

INFORMATION ON BATCH FILES

QUICK LINKS
Batch file ABCs
Creating a batch file
Batch commands
Batch file examples
Technical support
Debug Routines

BATCH FILE ABCs

Batch files are programs that all MS-DOS users can create to help do long tasks fast. Such as
opening certain programs ran frequently, deleting or managing files, etc. Simple batch files do
not require any special programming skills and usually can be done by knowing the below commands
and or just DOS commands.

A prime example of a batch file for someone whom may know more about Windows or MacOS would be
relating a batch file to a shortcut in Windows or with the MacOS, A batch file like a shortcut
is a small file which is used to run frequently accessed programs.

Another example of a very well known batch file is the autoexec.bat, which is simply a boot file
loaded each time the computer is loaded within this file contains various lines to load various
programs and drivers into memory.
CREATING A BATCH FILE
To create a basic batch file first get to a MS-DOS command prompt and follow the below
instructions:

At the MS-DOS prompt type edit test.bat and press enter.
If typed properly you should now be in a blue screen within the blue screen type:
pause
dir c:\windows
dir c:\windows\system
Once the above three lines have been typed in the blue screen choose file and choose exit, when
prompted to save click yes
Once you are back at the prompt type test. When you press enter this should execute the test.bat
file and begin running the file. Because the first line is pause you will first be prompted to
press a key. Once you press a key the batch file will run line by line in this case listing the
files in the windows and windows\system directory.
If you wish to add more lines to this batch file you would simply type edit test.bat again to
edit the file.


BATCH COMMANDS

Just like all DOS commands when creating batch files they are not case sensitive however in the
below listing we have listed all commands in all caps to help you identify what are batch file
commands.

@ Does not echo back the text after the at symbol. This is most commonly used as @ECHO OFF to
prevent any of the commands in the batch file from being displayed just the information needed.
%1 The percent followed by a numeric value, beginning with one, allows users to add variables
within a batch file. The following is a batch file example:
echo Hello %1
When the above one line batch file is created and adding your name after the batch file. For
example typing myname (being the name of the bat file) and then your name:
myname bob
would output
Hello bob
:LABEL By adding a colon in front of a word such as LABEL you create a GOTO category
CALL This is used to run another batch file within a batch file. When the batch file is done
running it will then continue with the original batch file if any other commands are under the
CALL statement. Note if the batch file does not exist it will give an error message.
CHOICE See running different programs for example of how to use this command.
CLS Just like the DOS command would clear your screen.
ECHO Will echo a message in the batch file. Such as ECHO Hello World when the batch file is ran
it will say Hello World. Note if you have not typed @ECHO OFF at the beginning of the file this
will say ECHO Hello World then Hello World. If you would just like to create a blank line type
ECHO. adding the period creates an empty line.
EXIT Exits out of the DOS window if the batch file is ran from Windows.
GOTO LABEL Used to go to a certain label such as LABEL. An example of GOTO would be to GOTO END.
For an Example of this see
IF Used to check for a certain condition if the condition exists it will do another function
within the batch file. To see an example of this see
PAUSE This will prompt the user to press any key to continue.
REM Allows you to place comments into the batch file without having them be ran.
SHIFT Changes the position of replaceable parameters in a batch program. You can use this
command only in batch programs.
START Used for Windows 95, Windows 98, and Windows NT 4.0 and above to start a windows
application such as START C:\WINDOW\CALC which would run the Windows Calculator. A similar
command for Windows 3.x would have to be run out of Windows by using the WIN command such as
WIN C:\WINDOWS\CALC.EXE which would run Windows and then Calculator after Windows has finish
loading.

BATCH FILE EXAMPLES

Running different programs
Deleting files in directory without prompt
How to start Windows 95 / 98 files from batch file
Creating a batch file delay
How to make time log

RUNNING DIFFERENT PROGRAMS

The following is a simple example of how you can implement the choice options into your batch
files. Each line that is in red can be left out of the batch file. They have been included to
help explain some of what the batch file means.

@ECHO OFF
REM - LABEL INDICATING THE BEGINNING OF THE DOCUMENT.
:BEGIN
CLS
REM - THE BELOW LINE GIVES THE USER 3 CHOICES (DEFINED AFTER /C:)
CHOICE /N /C:123 PICK A NUMBER (1, 2, or 3)%1
REM - THE NEXT THREE LINES ARE DIRECTING USER DEPENDING UPON INPUT
IF ERRORLEVEL ==3 GOTO THREE
IF ERRORLEVEL ==2 GOTO TWO
IF ERRORLEVEL ==1 GOTO ONE
GOTO END
:THREE
ECHO YOU HAVE PRESSED THREE
GOTO END
:TWO
ECHO YOU HAVE PRESSED TWO
GOTO END
:eek:NE
ECHO YOU HAVE PRESSED ONE
:END

HOW TO START WINDOWS 95 / 98 FILES FROM A BATCH FILE

To run files for Windows 95 or Windows 98 in a batch file you would use the START command. The
following example would run Windows Notepad.

START /M "C:\WINDOWS\NOTEPAD.EXE"

The /m representing it to start the window Maximized.

CREATING A BATCH FILE DELAY

The following is an example of how to delay a batch file any where from 5 to 99 seconds. In the
below example we illustrate a 5 second delay.

TYPE NUL | CHOICE.COM /N /CY /TY,5 >NUL

Additionally you could use the sleep file found on our utility download section.

HOW TO MAKE A TIME LOG

In the following example you will have the capability of creating a time log of when the batch
file is loaded or for example in the autoexec.bat when someone logs into a computer.

ECHO. |TIME > TIME
COPY LOG +TIME

An alternate slightly more complicated method that to our knowledge cannot be used in Windows
NT, Windows 2000 or Windows ME would be the following:

echo @prompt set date=$d$_set time=$t$h$h$h > {a}.bat
%comspec% /e:2048 /c {a}.bat > {b}.bat
for %%v in ({b}.bat del) do call %%v {?}.bat
echo %date% %time% >> log

For the above batch file to work properly you must create a file called log by typing "edit log"
(without the quotes) and then save an exit the file which will create the file at 0 bytes. If
this file is not created or not created properly you will receive the error message "Content of
destination lost before copy".