我正在爲我正在修補的基於文本的遊戲父級的子批處理文件工作。根據我的教授的指示,我必須使用一個如果不是的話。如果用戶在選擇之後選擇除「Y」之外的任何內容,我想將其放到哪裏,程序將退出。我試着用'if not exit'和'if not y == y exit',但是程序只是循環回到父批處理文件,不管選擇後的輸入。Windows批量使用If和If命令
如何保證我的if不退出語句總是關閉程序?注:程序是從桌面運行
:: Child Batch File
@echo off
Title Halloween......
color 06
echo set speech = wscript.Createobject("SAPI.spvoice") >> "temp.vbs"
set text=You cannot kill the boogie Man!
echo speech.speak "%text%" >> "temp.vbs"
start temp.vbs
pause
del temp.vbs
Echo Another Round??
Pause
cls
Choice
if y==y call scarymovie.bat
if not goto exit
:exit
父批處理文件:
@Echo Off
Title Slim Shady - Scary Movie
color 04
:start
set /a counter+=1
Echo You Have Run This Program %counter% times
Echo %counter% >> answers.txt
Echo Greetings Traveler, Scrawl Your Name Across The Screen
set /p name=
Echo %name% >> answers.Txt
Echo What's Your Favorite Scary Movie??
Pause
cls
Echo Press 1 for Halloween
Echo Press 2 for The Exorcist
Echo Press 3 for I Doesn't Afraid No Ghost
set /p movie=
Echo %movie% >> answers.txt
if %movie%==1 call Halloween.bat
if %movie%==2 call Exorcist.bat
if %movie%==3 Start www.SesameStreet.org
Pause
Cls
Ÿ== Y的總是會評估爲真。 https://en.wikipedia.org/wiki/Choice_(command)#Syntax –
爲什麼在父腳本中使用set/p在子腳本中選擇? 用set/p再次取代=的選擇=,然後 IF NOT%again%== y exit/b –
謝謝,我結束瞭如果if語句和if語句有選擇變量。 – CutAndJack