Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Batch Files - Create a Menu to Execute Commands

11 May 2016   #10
Bubbadama123

win 8.1
 
 

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-

Quote:
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-

Quote:
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.


My System SpecsSystem Spec
.
19 Aug 2016   #11
estoyeluno

Windows 7 Enterprise 64-bit and Windows 7 Ultimate 64 bit
 
 
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 Images
Batch Files - Create a Menu to Execute Commands-menu.jpg 
My System SpecsSystem Spec
24 Sep 2016   #12
reddwarf4ever

10 Home upgradd from 7
 
 
3rd party app as alternative to batch file

Is there a

3rd party app as alternative to batch file

Thanks
My System SpecsSystem Spec
12 Mar 2017   #13
jacky99

Windows 7 Ult x64
 
 
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.
My System SpecsSystem Spec
.

18 Jul 2017   #14
jalder

New South Wales
 
 

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 System SpecsSystem Spec
2 Weeks Ago   #15
Paul Black

Microsoft Windows 7 Home Premium 64-bit 7601 Multiprocessor Free Service Pack 1
 
 

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 System SpecsSystem Spec
Reply

 Batch Files - Create a Menu to Execute Commands




Thread Tools




Similar help and support threads
Thread Forum
Execute Program in Batch File As Administrator (Or Other Solution)
We use a program called TFC.exe (Temp File Cleaner - addpcs.com) to wipe all sorts of temp files off a computer on a monthly basis. The older version was a standalone .exe that users used to execute from a a folder on a server. The newer version is actually installed on each user's PC. If...
General Discussion
Using notepad(batch programing) to execute a comand at a specific time
Can anyone help me make a command using notepad that can execute a task at a given time?
System Security
Start Command Prompt and automatically execute a few commands
I am learning a programming language, and I frequently use command prompt to compile source codes, but every time I start command prompt I need to manually cd to the correct directory, and then I like to run cls to keep the window clean. I have looked around, but I'm not sure how to phrase a google...
Software
Execute copy-cut-paste commands via voice
I am looking for a way where I can execute the windows commands "ctrl-c", "ctrl-v" and "ctrl-x" by simply saying "copy", "paste" and "cut" into the microphone of my headset. So simple and verbally uncomplicated instructions, but need to be issued immediately without several seconds delay. First...
Software
execute commands on power event
Is there some way to configure Windows 7 to execute commands (such as resolution changing, killing/starting processes and services, etc.) whenever the laptop switches from AC to DC and back? I have been using batterysaver from codeplex.com but it is still in beta and hasn't seen any updates for...
General Discussion
automatically execute commands when switching to DC
Is there any way I can tell windows to execute various commands when I pull the power adapter from my laptop? For example, I could tell it to close certain background programs that drain battery life or to change the resolution automatically to save power.......
Performance & Maintenance


Our Sites

Site Links

About Us

Find 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 03:44.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App