September 21, 200322 yr Is it possible to make the batch file ask for user input?reason I ask is that I would like to copy certain files from my D: to my C: during the batch run but i'd like it to ask me if i'd want to or not and not bother coyping them?Thanks guys, great website you got here!
September 21, 200322 yr @ECHO OFFSET MyInput=IF NOT '%1'=='' GOTO ReadySET /P MyInput=Enter filename:copy %myinput% c:\This will help?
September 22, 200322 yr User input can be done thusly:@Echo OffEcho Press 1 if you want to copy filesEcho Press 2 if you do not want to copy filesEcho Please make your selection...After throwing that code in a batch file (notice it doesnt actually do anything besides display text, but ill get to that in a minute), create 2 more batch files. one named "1.cmd" and the other "2.cmd".In "1.cmd" you place all the files you want to copy, and in "2.cmd" you pick up the setup where you left off.Explanation:In the code above, all it does is print text and displays it to the user. When its done, it brings it back to the command prompt at the directory where the batchfile was run. In this directory is where you place 1.cmd and 2.cmd. When the user presses 1 or 2, it executes the appropriate batch file. Simple!You can ofcourse change the names of the 1.cmd and 2.cmd, except you'll need to prompt the user to type in the filename of the command file, rather then just 1 or 2.Hope this helps!
September 22, 200322 yr The following batch file snippet displays a simple menu (without a question-mark at the end of the prompt) and prompts for the users choice, defaulting to option 2 after 5 seconds :@ECHO OFFECHO 1. MS-DOS Editor.ECHO 2. MS-Windows. (default)ECHO 3. Defrag the hard-drive.ECHO 4. Quit.CHOICE /C:1234 /N /T:2,5 Please choose a menu option.IF ERRORLEVEL == 4 GOTO QUIT_MENUIF ERRORLEVEL == 3 GOTO DEFRAG_HDIF ERRORLEVEL == 2 GOTO RUN_WINIF ERRORLEVEL == 1 GOTO RUN_EDIT:RUN_EDITCALL EDIT:RUN_WINCALL WIN:DEFRAG_HDDEFRAG c::QUIT_MENUcredit: http://www.cs.ntu.edu.au/homepages/bea/hom...escription.html
September 22, 200322 yr Unfortunatly, the Choice command doesnt not work in Windows XP@ECHO OFFSET MyInput=IF NOT '%1'=='' GOTO QUIT_MENUECHO 1. MS-DOS Editor.ECHO 2. MS-Windows.ECHO 3. Defrag the hard-drive.ECHO 4. Quit.SET /P MyInput=Please choose a menu option:IF %MyInput% == 4 GOTO QUIT_MENUIF %MyInput% == 3 GOTO DEFRAG_HDIF %MyInput% == 2 GOTO RUN_WINIF %MyInput% == 1 GOTO RUN_EDIT:RUN_EDITCALL EDIT:RUN_WINCALL WIN:DEFRAG_HDDEFRAG c::QUIT_MENUThis will work.
September 22, 200322 yr Unfortunatly, the Choice command doesnt not work in Windows XP@ECHO OFFSET MyInput=IF NOT '%1'=='' GOTO QUIT_MENUECHO 1. MS-DOS Editor.ECHO 2. MS-Windows.ECHO 3. Defrag the hard-drive.ECHO 4. Quit.SET /P MyInput=Please choose a menu option:IF %MyInput% == 4 GOTO QUIT_MENUIF %MyInput% == 3 GOTO DEFRAG_HDIF %MyInput% == 2 GOTO RUN_WINIF %MyInput% == 1 GOTO RUN_EDIT:RUN_EDITCALL EDIT:RUN_WINCALL WIN:DEFRAG_HDDEFRAG c::QUIT_MENUThis will work. This code works but unfortunatly when you finish using option 1,2 or three it automatically runs on the the next option, this is a revised one which automatically goes back to the menu when finished..@ECHO OFF:STARTSET MyInput=IF NOT '%1'=='' GOTO QUIT_MENUECHO 1. MS-DOS Editor.ECHO 2. MS-Windows.ECHO 3. Defrag the hard-drive.ECHO 4. Quit.SET /P MyInput=Please choose a menu option:IF %MyInput% == 4 GOTO QUIT_MENUIF %MyInput% == 3 GOTO DEFRAG_HDIF %MyInput% == 2 GOTO RUN_WINIF %MyInput% == 1 GOTO RUN_EDIT:RUN_EDITCALL EDITGOTO START:RUN_WINCALL WINGOTO START:DEFRAG_HDDEFRAG c:GOTO START:QUIT_MENU
September 23, 200322 yr Hey guys, thanks for the quick tutorial on the batch commands. This is very helpful indeed. How would like someone write the code where the user picks up a menu choice and after it is done with that choice, it automatically continues on the installation without going back to the menu? For example, if I wanted to create this menu.1. Install Windows XP with original default.2. Install Windows XP (Tweaks Only)3. Install Windows XP (Tweaks and Themes)etc..Also, is there a way to log the output of display in a batch file? The line below the the CALL statement, is that a regular command file (filename.cmd)? I'm to all this stuff.-Kenneth
September 24, 200322 yr take a look at CD-Shellit´s more complicated.. but will do a much more comfortable menu at boot time.also it allowes much more to load, than just windows setup settings..in combination with the manual given on this site or this site u will get a very handy cd..
September 24, 200322 yr Author Is there a way to dump the whole batch file into a .txt after it has executed? As its quite hard to spot errors as things install too quickly
September 24, 200322 yr start another batch file and call your batch file with output to txt file like this:call yourbatch.cmd > log.txt
Create an account or sign in to comment