Batch Files - Create a Menu to Execute Commands

Page 2 of 2 FirstFirst 12

  1. Posts : 2
    win 8.1
       #10

    fixed the tutorial's example because of code errors and missing commands
    remade the example to Showing differance between using the start command than just running a path by itself.



    -Example 1-

    ECHO OFF
    CLS
    :MENU
    ECHO.
    ECHO ...............................................
    ECHO PRESS 1, 2 OR 3 to select your task, or 4 to EXIT.
    ECHO ...............................................
    ECHO.
    ECHO 1 - Open Notepad
    ECHO 2 - Open Calculator
    ECHO 3 - Open Notepad AND Calculator
    ECHO 4 - EXIT
    ECHO.
    SET /P M=Type 1, 2, 3, or 4 then press ENTER:
    IF %M%==1 GOTO NOTE
    IF %M%==2 GOTO CALC
    IF %M%==3 GOTO BOTH
    IF %M%==4 GOTO EOF
    :NOTE
    CLS
    ECHO Opening Notepad
    start notepad.exe
    GOTO MENU
    :CALC
    CLS
    ECHO Opening Calculator
    start calc.exe
    GOTO MENU
    :BOTH
    CLS
    ECHO Opening Notepad
    start notepad.exe
    ECHO Opening Calculator
    start calc.exe
    GOTO MENU
    :EOF
    EXIT

    -Example 2-

    CLS
    ECHO.
    ECHO ...............................................
    ECHO PRESS 1, 2 OR 3 to select your task, or 4 to EXIT.
    ECHO ...............................................
    ECHO.
    ECHO 1 - Open Notepad
    ECHO 2 - Open Calculator
    ECHO 3 - Open Notepad AND Calculator
    ECHO 4 - EXIT
    ECHO.
    SET /P M=Type 1, 2, 3, or 4 then press ENTER:
    IF %M%==1 GOTO NOTE
    IF %M%==2 GOTO CALC
    IF %M%==3 GOTO BOTH
    IF %M%==4 GOTO EOF
    :NOTE
    CLS
    ECHO Opening Notepad
    %windir%\notepad.exe
    GOTO MENU
    :CALC
    CLS
    ECHO Opening Calculator
    %windir%\system32\calc.exe
    GOTO MENU
    :BOTH
    ECHO Note: The notepad will run first then when its closed the calculator will run afterwards.
    pause
    CLS
    ECHO Opening Notepad
    %windir%\notepad.exe
    ECHO Opening Calculator
    %windir%\system32\calc.exe
    GOTO MENU
    :EOF
    EXIT

    Note: Can the OP fix the 1st post has made mistakes that even confused me.
    Last edited by Bubbadama123; 11 May 2016 at 22:14.
      My Computer


  2. Posts : 1
    Windows 7 Enterprise 64-bit and Windows 7 Ultimate 64 bit
       #11

    a code for selecting an option from a menu


    Hi everyone,

    This is the first batch file I've ever created and I'm creating it because at work we have to open about 15 different web browsers and applications to do our job and it's extremely tedious. I'm 95% percent done with the bat file but I'm stuck on one last step. To explain what I have so far, and please if you have any tips to make it better or more efficient, I'd love the feedback. The code is very simple, i start it with an @echo off and I'm basically launching several Chrome windows, 1 Firefox window and 3 IE windows. And then I'm opening, Outlook. I have all of those opening smoothly using a CD "location" Start ".exe" code.

    The final program I need to launch is an internal program we use to manage our clients. I need to have 9 instances of this window open, and each window requires you to select from a drop down menu which version you wish to access. I am able to launch all 9 windows with no problem, however I am stuck on how to make the bat select the correct version I need. If I can get it to select OK as well, that'd be awesome.

    But my question is, how do I code the bat file to launch the application and then select from the drop down menu the version I need? I attached a screenshot of how the application opens. Please let me know if it didn't work.

    Thanks for your help!!!
    Attached Thumbnails Attached Thumbnails Batch Files - Create a Menu to Execute Commands-menu.jpg  
      My Computer


  3. Posts : 10
    10 Pro
       #12

    3rd party app as alternative to batch file


    Is there a

    3rd party app as alternative to batch file

    Thanks
      My Computer


  4. Posts : 28
    Windows 7 Ult x64
       #13

    How to make commands with wildcard combination to delete a folder


    I always use a batch file to easily remove unnecessary files in %TEMP% that I put in my Startup on Startmenu.
    But I had trouble using a combination wildcard asterisk(*) to delete a folder with its name contains a dot(.) mark.
    Here's details, if I open Photoshop CS6, there always made 8-9 useless files (files + folders) in profile Temp. There is no problem to remove all by using batch file, but there is one obstacle for me to remove it using asterisk to a folder as the name lilo.3248.

    Actually, it's so easy to remove if I use full name, example:
    Code:
    @echo off
    if exist %TEMP%\lilo.3248 rd /s /q %TEMP%\lilo.3248 => works without problem
    But it's a problem if I try using wildcard(*), like this:
    Code:
    @echo off
    if exist %TEMP%\lilo.* rd /s /q %TEMP%\lilo.* => failed
    if exist %TEMP%\lil*.* rd /s /q %TEMP%\lil*.* => Same failed
    Why I use a wildcard.. because the figures after the dot could always be changed to new numbers each time when I open new Photoshop, sometimes 3digits, sometimes 4digits erratically. The numbers were created randomly as lilo.743, lilo.2935 etc.. Therefore I use wildcards to be easier, but failed.
    I confused, for directory name without dot + wildcard, I usually can remove them easily. However, this method not work to this case.

    So, does anyone know how to make the commands work according to my needs like above? Thanks in advance.
    Last edited by jacky99; 13 Mar 2017 at 08:19.
      My Computer


  5. Posts : 1
    New South Wales
       #14

    This great thanks, I'm looking for a more advanced version and the menu to by dynamic based on the folders existing within a path, can anyone help me?

    So I have various folders with in a folder, like this:
    \FOLDER\?
    \FOLDER\??
    \FOLDER\???
    \FOLDER\???
    And seemingly the ??? folders could be anything and I cannot predict the folder names.

    I want to create a dos menu system to give the user a multiple choice of which folder to choose:
    ? or ?? or ?? or ?? or whatever else is there (at that level) ignoring any sub folders in their ? folders.

    And then based on the users selection, insert that path into a variable so I can use it with a command
    eg: XCOPY %VARIABLE% TO MY PATH
    so if the user choose \FOLDER\djfng
    then my commnd is XCOPY "FOLDER\djfng" TO MY PATH

    Can anyone help me?

    thank you thank you
      My Computer


  6. Posts : 6,021
    Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
       #15

    Good afternoon,

    Just a couple of points please.

    Firstly, does the file need to be saved in the Computer > C: > Windows > System32 directory?

    Secondly, how easy would it to create a batch file with a menu...

    Administrative Tools.
    CCleaner.
    Command Prompt.
    Computer Management.
    Defrag.
    Device Manager.
    Disk Management.
    Notepad.
    Performance Information and Tools.
    Personalization.
    Power Options.
    Programs and Features.
    Security Centre.
    System.
    Taskbar and Start Menu.
    User Accounts.
    Windows Update.

    ...or is this beyond that please?

    Thanks in advance.
      My Computer


  7. Posts : 759
    Microsoft Windows 7 Ultimate 64-bit 7601 Multiprocessor Free Service Pack 1
       #16

    hi,

    I am newbie in programming
    please kindly supply a batch code to execute a batch file to know the status page details

    i use telnet ip x x x x to go to router page
    then i want to get the userid: as admin and it should automatically Enterkey to get password. i want this to be automated

    after entering , the promtwill give password:, this i will fill my pw
    after this i wll get to telnet screen with prompt c:\windows\system32>
    Here iwill issue command show status
    This will give the details of the router status page
    This details should be shown in desktop, waiting for my closing.
    after closing, the program should stop execute. If some experts give codes for batch file, i will make ti execute with task scheduler
    Now, each time i have to login to the router and supply pw to get the status age.
    expecing your replies
      My Computer


  8. Posts : 759
    Microsoft Windows 7 Ultimate 64-bit 7601 Multiprocessor Free Service Pack 1
       #17

    Hi, notso grey matter,

    As the author of the tutorial, if you could help me coin codes for my task
    just 5 to ten lines of codes, which i do not know
    it is very useful if the status of router could be had in the desktop itself
    hope that you would see this post
    or any other experts,
    Batch Files - Create a Menu to Execute Commands Attached Files
    Last edited by jraju; 28 Jan 2019 at 07:54.
      My Computer


  9. Posts : 28
    Windows 7 Ult x64
       #18

    jraju said:
    i use telnet ip x x x x to go to router page
    then i want to get the userid: as admin and it should automatically Enterkey to get password. i want this to be automated...
    after closing, the program should stop execute. If some experts give codes for batch file, i will make ti execute with task scheduler
    I don't know exactly what you mean, but please try to see here.. hoping solve your problem:
    How to schedule a Batch File to run automatically
      My Computer


 
Page 2 of 2 FirstFirst 12

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 01:28.
Find Us