Thursday, October 15, 2015

Having a problem executing .bat file (sub-menu) through .bat file (menu)



I have created a batch file menu (named "menu.bat") which lists three sub-menus linked to their respective batch files, as follows:




  1. Network Functions (networkfunctions.bat)

  2. Control Panel (controlpanel.bat)

  3. Accessories (accessories.bat)




The batch filename of each selection (i.e., 1, 2, 3) is in parentheses.



I have all these .bat files saved on my computer in the following directory structure:



c:\batch






Here is the script found in menu.bat:




echo off
title Main Menu
::menu.bat
::Contains main batch file menu
cls
:menu
echo.
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º MY NAME HERE ÄÄ Main Menu º
echo ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹

echo º 1. Network Functions º
echo º 2. Control Panel º
echo º 3. Accessories º
echo º 4. Exit º
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
echo.
set /p input="Select number: "
if %input% ==4 goto Exit
if %input% ==3 goto Accessories

if %input% ==2 goto Control Panel
if %input% ==1 goto Network Functions

:Network Functions
start c:\batch\networkfunctions.bat
pause
goto menu

:Contol Panel
start c:\batch\controlpanel.bat

pause
goto menu

:Accessories
start c:\batch\accessories.bat
pause
goto menu

:Exit
exit






Here is the script in network.bat:



echo off
title Network Functions
::networkfunctions.bat
::contains network functions and utilities for use on the

::command prompt
cls
:menu
echo.
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º MY NAME HERE Ä Network Functions º
echo ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
echo º 1. IPCONFIG º
echo º 2. IPCONFIG /ALL º
echo º 3. NETSTAT º

echo º 4. NSLOOKUP º
echo º 5. Telnet º
echo ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĹ
echo º 6. Return to Main Menu º
echo º 7. Exit º
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
echo.
set /p input="Select number: "
if %input% ==7 goto Exit

if %input% ==6 goto Return to Main Menu
if %input% ==5 goto Telnet
if %input% ==4 goto NSLOOKUP
if %input% ==3 goto NETSTAT
if %input% ==2 goto IPCONFIG /ALL
if %input% ==1 goto IPCONFIG

:IPCONFIG
start c:\windows\system32\ipconfig.exe
pause

goto menu

:IPCONFIG /ALL
start c:\windows\system32\ipconfig.exe \all
pause
goto menu

:NETSTAT
start c:\windows\system32\netstat.exe
pause

goto menu

:NSLOOKUP
start c:\windows\system32\nslookup.exe
pause
goto menu

:Telnet
start c:\windows\system32\telnet.exe
pause

goto menu

:Return to Main Menu
start c:\batch\menu.bat
pause
goto menu

:Exit
exit






Here is the script in controlpanel.bat:



echo off
title Control Panel
::controlpanel.bat
::contains a menu of pertinent control panel applets
cls

:menu
echo.
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º MY NAME HERE Ä Control Panel º
echo ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
echo º 1. Configuration Manager º
echo º 2. Internet Options º
echo º 3. Network Connections º
echo º 4. System Properties º
echo º 5. Windows Firewall º

echo ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĹ
echo º 6. Return to Main Menu º
echo º 7. Exit º
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
echo.
set /p input="Select number: "
if %input% ==7 goto Exit
if %input% ==6 goto Return to Main Menu
if %input% ==5 goto Windows Firewall

if %input% ==4 goto System Properties
if %input% ==3 goto Network Connections
if %input% ==2 goto Internet Options
if %input% ==1 goto Configuration Manager

:Configuration Manager
start rundll32.exe shell32.dll,Control_RunDLL C:\WINDOWS\system32\CCM\SMSCFGRC.cpl
pause
goto menu


:Internet Options
start rundll32.exe shell32.dll,Control_RunDLL c:\windows\system32\inetcpl.cpl
pause
goto menu

:Network Connections
start rundll32.exe shell32.dll,Control_RunDLL c:\windows\system32\ncpa.cpl
pause
goto menu


:System Properties
start rundll32.exe shell32.dll,Control_RunDLL c:\windows\system32\sysdm.cpl
pause
goto menu

:Windows Firewall
start rundll32.exe shell32.dll,Control_RunDLL c:\windows\system32\firewall.cpl
pause
goto menu


:Return to Main Menu
start c:\batch\menu.bat
pause
goto menu

:Exit
exit






Here is the script in accessories.bat:



echo off
title Accessories
::accessories.bat
::contains a menu of pertinent utilities and applications
cls
:menu
echo.
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»

echo º MY NAME HERE Ä Accessories º
echo ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
echo º 1. DOS Edit º
echo º 2. Notepad º
echo º 3. System Information º
echo º 4. System Restore º
echo ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĹ
echo º 5. Return to Main Menu º
echo º 6. Exit º
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

echo.
echo.
set /p input="Select number: "
if %input% ==6 goto Exit
if %input% ==5 goto Return to Main Menu
if %input% ==4 goto System Restore
if %input% ==3 goto System Information
if %input% ==2 goto Notepad
if %input% ==1 goto DOS Edit


:DOS Edit
start c:\windows\system32\edit.com
pause
goto menu

:Notepad
start c:\windows\system32\notepad.exe
pause
goto menu


:System Information
start c:\program files\common files\microsoft shared\msinfo.exe
pause
goto menu

:System Restore
start c:\windows\System32\restore\rstrui.exe
pause
goto menu


:Return to Main Menu
start c:\batch\menu.bat
pause
goto menu

:Exit
exit






THE PROBLEM






I can execute menu.bat successfully. I am presented with the three selections.




  1. Network Functions

  2. Control Panel

  3. Accessories




If I select "1," I am taken to "Network Functions" sub-menu. Perfect.



If I select "3," I am taken to "Accessories" sub-menu. Perfect.



If I select "4," I exit the Windows Command Line. Perfect.



The problem is if I select "2"; it provides the following error:




The system cannot find the batch label specified - control


The drive label then changes from c:\ to c:\batch.



The curious thing is that I CAN execute the file c:\batch\controlpanel.bat if I enter it in the Run box. It works perfectly.



But, if I try to execute it through the menu.bat file, it does not execute.



What's going on here? Any help is appreciated. I'm this close to finishing this class project.




Thank you in advance.


Answer



You misspelled Control Panel as Contol_Panel.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...