2016-11-08 81 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