• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

DOS Batch file help

JuBeiX

Junior Member
I just need some help creating some batch files. The first batch file I want it to do is copy the following files from my C:\tools to A:\
fdisk.exe
format.com
edit.com
qbasic.exe
scandisk.exe

The second one I need help on is a batch file that can provide the user with 3 options: 1. run fdisk 2. run edit.com 3. run scandisk.

Any help would be much appreciated, thx.
 
Sorry. Haven't really done the 2nd one

But for the 1st one:

cd c:\tools
copy disk.exe a:\
copy format.com a:\
copy edit.com a:\
copy qbasic.exe a:\
copy scandisk.exe a:\

Good luck
 
Quick and dirty on the menu batch file:

Contents of menu batch (menu.bat)file:

cls
type menu.txt

Contents of "menu.txt":

1. run fdisk
2. run edit
3. run scandisk

Contents of "1.bat":

fdisk

Contents of "2.bat":

edit

Contents of "3.bat":

scandisk

You'll have to include the appropriate path to point to "menu.txt" if it isn't in the current directory, and you'll need to include the appropriate path to point to 1.bat, 2.bat, and 3.bat if they're not in the current path.

There are more elegant ways to do this using a single batch file which includes all menu and batch file content. That seems a bit beyond the scope of a quick message to explain. If you want to figure out how to do this, go to a command prompt, and type "if /?" and hit return. (Or you can type "if /?>if.txt to get a text file in the current directory that will tell you how to use the if command.) Understanding "if" is the first step in doing the single batch file thing.

Regards,
Jim

Edit: BTW, another reason I suggest the quick and dirty method is that it's easier to alter, delete or add new functions. To add something new, just add a line to "menu.bat", and create a new #.bat file to perform the function. You get the idea. Making changes in the functionality of the all-in-one batch / menu file is somewhat more involved.
 
here is a batch file that I did some time ago, you can see how the
functionality is done pretty easily.
%1 %2 %3 are all the command line options passed through to the batch
file.

choice /c:1234 Choose one:
if errorlevel 4 goto end
if errorlevel 3 goto nummaps
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this stuff gives you ability to do a menu,
you have to do it 4, 3 ,2,1 in that order 🙂 I think 🙂
Then when you do goto, you put in a label, like goto end goes to :end, etc.



@echo off
if "%1"=="/?" goto help
if "%1"=="?" goto help
if "%1"=="-?" goto help
if "%1"=="/s" goto comsetup
if "%1"=="/d" goto comduke
if "%1"=="/n" goto nummaps
if "%1"=="/r" goto resmaps
if "%1"=="/nifty" goto menu

goto runduke


:menu

cls
echo Welcome to the Wild World of MoMaps!
echo.
echo 1. Run Duke3d using Momap's modified con file
echo 2. Run Setup (and from there multiplayer, m2m) using Momap's con file
echo 3. Copy maps to e1l1.map through e3l11.map
echo 4. Exit
echo.
echo - After duke3d has started, select episode 1, 2 or 3 to run Momaps
echo.
echo - This file will NOT modify any con files. It runs setup or
echo duke3d with the command line "/xmosimple.con"
echo.
echo - All command line parameters are passed through to setup
echo or duke3d. So you can type "mm /s3" to get to a higher skill level.
echo.
echo - Option #3 will copy all the map files to files of the form e1lx.map,
echo e2lx.map & e3lx.map. So you can run all the MoMaps without using ANY
echo con file change (or use your own con file mod) if you want to.
echo.
echo - To run MoMaps in a case where you can't run duke3d through setup,
echo (like if you are using a service like TEN), run mm2.bat. Read
echo momaps.txt first for more info.
echo.

choice /c:1234 Choose one:
if errorlevel 4 goto end
if errorlevel 3 goto nummaps
if errorlevel 2 goto runsetup
if errorlevel 1 goto runduke
goto end

:help
echo.
echo Usage: mm (options)
echo.
echo Options:
echo -------
echo /? = This menu
echo /s = Run setup with modified con file
echo /d = Run duke with modified con file
echo /n = Copy maps to files e1lx.map, e2lx.map and e3lx.map
echo /r = Restore backed up e2(3)(1)lx.maps and delete written
echo e2(3)(1)lx.maps
echo /nifty = Gives you a nifty menu with the above options
echo.
echo.
echo - "/d" is assumed when no other parameters are specified.
echo.
echo - All parameters are passed through to duke3d or setup
echo.
echo Example: "mm /v1 /l1 /s1" starts you at e1l1 at skill 1
echo.
echo - You can start modem and network games from setup using
echo "mm /s" and then the MoMaps maps will play when duke3d
echo starts.
echo.
goto end

:comsetup
shift
goto runsetup
goto end

:comduke
shift
goto runduke
goto end

:nummaps
call mm2 /nmaps
goto end

:resmaps
call mm2 /r
goto end

:runduke
echo.
echo MoMaps v1.01 for Duke3d v1.3d
call mm2 /v /q
duke3d /xmosimple.con %1 %2 %3 %4 %5 %6 %7 %8 %9
goto end


:runsetup
echo.
echo MoMaps v1.01 for Duke3d v1.3d
call mm2 /v
pause
setup /xmosimple.con %1 %2 %3 %4 %5 %6 %7 %8 %9
goto end

:runmm2
echo.
echo You can run this seperately at any time by typing "mm2"
echo.
pause
mm2
goto end



:end
 
Here is something more or less correct.. also if you have the dos help file, it lists all the dos and batch conventions and things. If you are using this in a boot disk, you can also do config.sys start menus and then it will pass a environment variable (try "set" in a dos prompt) that tells it which config it used and then you can set one of your lables in the autoexec to that name and goto the config to do something different in that config. Kind of complicated.. but neat (more so when dos games needed 10 different configs to run)






@echo off rem keeps from displaying whole text as it's processed
echo. rem dot for just a space
echo 1. run fdisk
echo 2. run edit
echo 3. run scandisk

choice /c:123 Choose one:
if errorlevel 3 goto runScanDisk
if errorlevel 2 goto runEdit
if errorlevel 1 goto runfDisk

rem I don't think it ever allows anything else through
rem but just in case
goto end

:runScanDisk
scandisk rem or something like that
goto end

:runEdit
edit rem or something like that
goto end

:runFdisk
fDisk rem or whatever 🙂
goto end

:end

 
doh!

for quick and dirty, try

copy con batchfile.bat
@echo off rem to turn off echo of everything
c:
cd/win98
del *.*
(type control-z) (enter)

then when you type "batchfile" it will erase (after prompt I think ?)
everything in c:\win98. You basically just type in everything the way you would otherwise, except "echo x" prints X.
 
Back
Top