2016-11-08 79 views
-1

這裏是我的問題:設置命令的批量崩潰?

:NNEEWW 
cls 
echo Where to save the file (Type "Desktop" or "Docs") 
set /p SaveTo="Where to save: " 
if "%SaveTo%" == "Desktop" goto DT 
if "%SaveTo%" == "desktop" goto DT 
if "%SaveTo%" == "Docs" goto DC 
if "%SaveTo%" == "docs" goto DC 
goto NNEEWW 
:DT 
set Place=DE 
:DC 
set Place=DO 
cls 
echo 'Name your file [You can not add the following: \/: * ? " < > |]' 
set /p name="Name: " 
echo echo off>>"Current.BAT" 
echo cls>>"Current.BAT" 
title Editing: %name%.BAT - Program Creator 
cls 
echo Editing %name%.bat [Type "Quit" to save and quit, Type "Help" to get some help with commands] 
echo [@echo off has already been added, to get rid of it, type "echo on", without an @ symbol please] 
echo "Please do not add ['>', '|', '<'] as they are not yet supported" 
echo. 
:2 
set /p content="[-]: " 

現在每當有人類型的「文檔」或「桌面」節目剛剛崩潰!我認爲這與set命令有關,但我不確定。

+0

地點集合後= DE,你想做些什麼來跳過去設置的地方做。但這不是問題。文檔和桌面可能只是讓你通過循環。你有沒有嘗試添加一些回聲和暫停命令,讓你確切地知道哪一行崩潰? –

+0

如果您選擇DT,place將始終等於DO,因爲您將其設置爲DE後執行它。另外'If/I'不區分大小寫比較(它隱藏在Help中)。 – 2016-11-08 03:21:19

+0

@Noodles告訴用戶在他最後一個問題中閱讀幫助文件。我想我的建議不是一個合理的選擇。 – Squashman

回答

2

代替GOTO的使用if-else結構:

:NNEEWW 
CLS 
ECHO Where to save the file (Type "Desktop" or "Docs") 
SET/P "SaveTo=Where to save: " 
IF /I "%SaveTo%" == "Desktop" (
    SET "Place=DE" 
) ELSE (
    IF /I "%SaveTo%" == "Docs" (
     SET "Place=DO" 
    ) ELSE (
     GOTO :NNEEWW 
    ) 
) 
CLS 
ECHO Name your file… 
+0

這看起來不錯,而且還修復它總是保存到文檔。 – NizonRox