首页 > 解决方案 > How do I make a batch file that opens certain programs?

问题描述

cls
@ECHO OFF
title Heirloom SS Tool
:MENU
ECHO.
ECHO __________________________
ECHO|     Select SS Option     |
ECHO --------------------------
ECHO.
ECHO 1 -> Open Horion Folder
ECHO 2 -> Open Advanced Search Tool
ECHO 3 -> Open UserAssistView
ECHO 4 -> Open LastActivityView
ECHO 5 -> Open ProcessHacker
SET /P M=Type 1, 2, 3, 4 or 5 then press ENTER:
IF %M%==1 GOTO Horion
IF %M%==2 GOTO Search
IF %M%==3 GOTO UAV
IF %M%==4 GOTO LAV
IF %M%==5 GOTO PH
:Horion
explorer C:\Users\%USERNAME%\AppData\Local\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\RoamingState
GOTO MENU
:Search
cd Tools\Search
start everything.exe
GOTO MENU
:UAV
cd Tools\UAV
start UserAssistView.exe
GOTO MENU
:LAV
cd Tools\LAV
start LastActivityView.exe
GOTO MENU
:PH
cd Tools\ProccessHacker
start ProcessHacker.exe
GOTO MENU
EXIT

Basically im trying to make a batch file that opens these certain files that i put in the same folder as this batch. When i start the batch file it just opens a CMD Prompt for a second and then closes! Can anyone help me solve this?

标签: batch-file

解决方案


You need to escape special characters redirect > and pipe | using caret ^ as already mentioned to you by @Neko in a comment.

I would however rather use choice instead of set /p

cls
@echo off
title Heirloom SS Tool
:menu
echo.
echo  __________________________
echo ^|     Select SS Option    ^|
echo  --------------------------
echo.
echo 1 -^> Open Horion Folder
echo 2 -^> Open Advanced Search Tool
echo 3 -^> Open UserAssistView
echo 4 -^> Open LastActivityView
echo 5 -^> Open ProcessHacker
choice /c 12345 /M "Select: "

goto choice%errorlevel%

:choice5
echo cd Tools\ProccessHacker
echo start ProcessHacker.exe
goto menu

:choice4
echo cd Tools\LAV
echo start LastActivityView.exe
goto menu

:choice3
echo cd Tools\UAV
echo start UserAssistView.exe
goto menu

:choice2
echo cd Tools\Search
echo start everything.exe
goto menu

:choice1
echo explorer "C:\Users\%USERNAME%\AppData\Local\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\RoamingState"
goto menu
:choice0
exit

You can read more about choice by running choice /? from cmd


推荐阅读