Cool thanks, i'll stick with what I have now. Just really need to get a footer in place with out to rewrite the entire thing.
You don't need to re-write anything, just use copy and paste. all this menu script requires are, (in this case), 11 files, most of which you already have: batchfile1 batchfile2 batchfile3 batchfile4 batchfile5 batchfile6 batchfile7 batchfile8 batchfile9 batchfile10 WPEUtil.exe
Ok would it look something like this? Code: @Echo Off & SetLocal Title place title here Color 1f If "%CD%\" NEq "%~dp0" PushD %~dp0 Set RunCount=0 :MENU Echo( ======================================================================= Echo( PLACE HOLDER FOR MENU TITLE Echo( ======================================================================= Echo( [A] - Select This Option Echo( - Select This Option Echo( [C] - Select This Option Echo( [D] - Select This Option Echo( [E] - Select This Option Echo( [F] - Select This Option Echo( [G] - Select This Option Echo( [H] - Select This Option Echo( - Select This Option Echo( [J] - Select This Option Echo( ======================================================================= Choice /C ABCDEFGHIJQ /N /M " Choose a menu option [A-J], or [Q] to Quit: " Set ReturnCode=%ErrorLevel% If %ReturnCode% Gtr 10 (If %RunCount% Equ 0 (GoTo :EOF) Else (GoTo :QUIT)) Set/A RunCount+=1 Call batchfile1%ReturnCode% Call batchfile2%ReturnCode% Call batchfile3%ReturnCode% Call batchfile4%ReturnCode% GoTo :MENU :QUIT Cls Echo( ======================================================================= Echo( QUIT MESSAGE GOES HERE Echo( ----------------------------------------------------------------------- Echo( Press [R] to Restart PC or to Shutdown Echo( ======================================================================= Choice /C RS /T 10 /D R /N /M " System will Auto Reboot in 10 seconds: " IF ErrorLevel 2 (WPEUtil Shutdown & Exit/B) WPEUtil Reboot And how do I get the footer in. Slave mentioned one way but is there another way to with out totally rewritting
In case you offer only one menu there's no real need for headers/footers . I use them to avoid redundant code by using one 'header/footer-call-module' for each.
No problem. When using call commands you can send parameters with the call, it only needs to prepare the called 'module in the script to use them. Syntax would be (to get a clue): The call command (parameters are separated by commas) Code: set "count=0" for /r "%cd%" %%a in (*.*) do set /a count+=1 call :InfoFooter "Processed all files.", "Files count: %count%" The count loop i only used to give a clue . The called Module (placeholders would be %~1 and %~2 here) Code: ::=============================================================================================================== ::INFO FOOTER :InfoFooter echo -------------------------------------------------------------------------------- echo %~1 echo %~2 echo -------------------------------------------------------------------------------- goto:eof The module must end with goto:eof. Will show as: Code: -------------------------------------------------------------------------------- Processed all files. Files count: XXX --------------------------------------------------------------------------------
I don't understand why you've changed my code to do something different! My intention was that if you selected: A then batchfile1.(cmd|bat) would have been called before returning to the menu selection process. B then batchfile2.(cmd|bat) would have been called before returning to the menu selection process. C then batchfile3.(cmd|bat) would have been called before returning to the menu selection process. D then batchfile4.(cmd|bat) would have been called before returning to the menu selection process. E then batchfile5.(cmd|bat) would have been called before returning to the menu selection process. F then batchfile6.(cmd|bat) would have been called before returning to the menu selection process. G then batchfile7.(cmd|bat) would have been called before returning to the menu selection process. H then batchfile8.(cmd|bat) would have been called before returning to the menu selection process. I then batchfile9.(cmd|bat) would have been called before returning to the menu selection process. J then batchfile10.(cmd|bat) would have been called before returning to the menu selection process. Q then the menu selection process would end. If A-J had not been selected then the script would exit If A-J had been selected then the shutdown/reboot procedure would be run. Now you have it so that if the end user selects, for instance, D then all of the following would happen: batchfile14 would be called. batchfile24 would be called. batchfile34 would be called. batchfile44 would be called before returning to the menu selection process. [EDIT] Code: @Echo( Code Removed [/EDIT]
Learning in progress for me. My knowledge with creating batch files is not on the same level as yours and others. Not sure what all i changed to make you upset. Thank you for the help.
First of all I did not say I was upset, I stated that I didn't understand why you'd changed my code, (especially as I'd told you to just copy and paste it). The code you'd changed, was highlighted within a quote section within my response, (unlike your posts, I tend to only quote that which is pertinent to my response).
Ok got everything going now. However im seeing something very strange now. When I boot into the WinPE. Startnet.cmd just opens up multiple command prompt windows. Something is borked with my menu script. If I execute it manually from a PC then no problems. But when I execute inside WinPE it loops. Here is my jacked up code. Code: @ECHO OFF pushd %~dp0 SetLocal EnableDelayedExpansion :color and title color 1f title TITLE - 12/12/2014 :Set some defaults for later :MAINMENU CLS IF NOT "!CD!"=="%~dp0" cd /D "%~dp0" ECHO =============================================================================== ECHO. *** TITLE *** ECHO =============================================================================== ECHO. ECHO. [A] - Command Prompt ECHO. - Powershell ECHO. ECHO. [C] - OPTION1 ECHO. ECHO. [D] - OPTION3 ECHO. [E] - OPTION4 ECHO. [F] - OPTION5 ECHO. ECHO. [G] - OPTION6 ECHO. ECHO =============================================================================== ECHO. *** TITLE *** ECHO =============================================================================== CHOICE /C ABCDEFGHIJq /N /M "Choose a menu option [A-F], or [Q] to Quit: " if %errorlevel%==1 goto :SelectionA if %errorlevel%==2 goto :SelectionB if %errorlevel%==3 goto :SelectionC if %errorlevel%==4 goto :SelectionD if %errorlevel%==5 goto :SelectionE if %errorlevel%==6 goto :SelectionF if %errorlevel%==7 goto :SelectionG if %errorlevel%==11 goto:QUIT :SelectionA CLS START CMD GOTO :MAINMENU :SelectionB CLS START POWERSHELL GOTO :MAINMENU :SelectionC CLS ECHO =============================================================================== ECHO *** CHANGE ME LATER *** ECHO =============================================================================== ping -n 10 192.168.34.67 if errorlevel 1 ( cls ECHO =============================================================================== ECHO *** Failed, press any key to continue *** ECHO =============================================================================== pause>nul exit ) ECHO. ECHO =============================================================================== ECHO *** Success, press any key to continue *** ECHO =============================================================================== pause>nul CLS GOTO :MAINMENU :SelectionD CLS CALL main_selectionD.cmd GOTO :MAINMENU :SelectionE CLS CALL main_selectionE.cmd GOTO :MAINMENU :SelectionF CLS CALL Main_Selection_F.cmd GOTO :MAINMENU :SelectionG CLS CALL Main_Selection_G.cmd GOTO :MAINMENU :QUIT CLS ECHO =============================================================================== ECHO. *** LEAVING *** ECHO ------------------------------------------------------------------------------- ECHO. Press ^(R^) to Restart PC or ^(S^) to shutdown ECHO =============================================================================== choice /c rs /t 10 /d r /n /m "System will reboot after 10 seconds ^(R/S^): " IF !ERRORLEVEL! EQU 1 WPEUTIL reboot WPEUTIL shutdown
Well you haven't really got it! have you? You have completely ignored the majority of the help others have attempted to give you and produced something which has no bearing to that which you opened this Topic. As of now I cannot be bothered to fix your entire script, but lets start by changing the first 37 lines, (quoted above), to this: Code: @Echo( Code Removed
Well thanks, it error'd out saying CHOICE was not an available command then exited out of the WinPe session. FYI I also tried your previous posted suggestion and it also gave the same exact error *shrugs*.
You need to add choice.exe and choice.exe.mui (from laguage folder in system32) to WinPE. Did this with my Win8.1SE with files from my Win 8.1. Wrks flawlessly . else you can use set /p command, which doesn't need choice.exe. Code: :MAINMENU CLS IF NOT "%CD%\"=="%~dp0" CD /D %~dp0 ECHO =============================================================================== ECHO. *** TITLE *** ECHO =============================================================================== ECHO. ECHO. [A] - Command Prompt ECHO. - Powershell ECHO. ECHO. [C] - OPTION1 ECHO. ECHO. [D] - OPTION3 ECHO. [E] - OPTION4 ECHO. [F] - OPTION5 ECHO. ECHO. [G] - OPTION6 ECHO. ECHO =============================================================================== ECHO. *** TITLE *** ECHO =============================================================================== set /p userchoice=Choose a menu option [A-F], or [Q] to Quit: if "%userchoice%"=="A" goto :SelectionA if "%userchoice%"=="B" goto :SelectionB if "%userchoice%"=="C" goto :SelectionC if "%userchoice%"=="D" goto :SelectionD if "%userchoice%"=="E" goto :SelectionE if "%userchoice%"=="F" goto :SelectionF if "%userchoice%"=="G" goto :QUIT goto :MAINMENU
Okay that makes perfect sense now that you mention it. I was in a hurry and used powershell to manually create a new winpe wim for me. Did not realize that forgetting to add certain packages would make things go nuts. I added those two files back and it's smooth sailing now. Thanks!!