批错误(未知)

时间:2014-11-27 20:25:22

标签: windows batch-file cmd

我试图运行一个文件来打开twitch feed ex-browser(它非常好)但是弹出错误:":此时出乎意料。" 我知道看起来我已经随意地放了一个:在那些不应该的代码中,但我已经检查过了。 我将下面的代码放在下面,可能还有其他错误,(我无法运行它来进行故障排除),代码如下。

@echo off

color 0a

echo Intitializing......

echo Done loading! (0.0026s) To continue,

pause

cd C:\Users\Harry\Desktop\Everything

tree

GOTO Startup


:Startup

cls

SET /P Answer=Do you want to watch your favorite twitch users?(1) Or enter a custom user?(2) Or add a user to your favorites(3)

if "%Answer%" == "1" (

GOTO Favorite

) else (

if "%Answer%" == "2" (

GOTO Questions

) else (

if "%Answer%" == "3" (

GOTO AddUser

) else (

echo *facepalm*

GOTO Startup

)





:Questions

cls

SET /P User=Who do you want? (Enter twitch user you want to watch): 

SET /P Quality=What quality do you want? (low/medium/high/source(highest)/audio/mobile(lowest))

SET /P Verify=So you want to watch %User% at %Quality% quality? (yes/no): 

if "%Verify%" == "yes" (

GOTO Stream

) else (

if "%Verify%" == "Yes" (

GOTO Stream

) else (

if "%Verify%" == "no" (

GOTO Questions

) else (

if "%Verify%" == "No" (

GOTO Questions

) else (

echo *facepalm*

GOTO Questions

)



:Stream

cls

livestreamer twitch.tv/%User% %Quality%

GOTO Questions



:AddUser

if exist {save1.txt} (

set check = 4

GOTO Load

) else (

set numb=0

GOTO AddUser1

)



:AddUser1

set person%numb% = ""

SET /P User=Please enter the user: (Enter twitch user you want to add):

%User% = %person%%numb%

set check = 1

GOTO Save

)




:Favorite

if exist {save1.txt} (

set check = 3

GOTO Load

) else (

set numb=0

set check = 2

)

:Favorite1

cls

GOTO Save



:Favorite2



:Save



echo %numb% > save1.txt

echo %person%numb%% > save.txt



if "%check%" = 4 (

GOTO Startup

) else (

if "%check%" = 3 (

GOTO Favorite1

)



:load

< save1.txt (

SET /P numb=

)

< save.txt (

SET /P person1=

SET /P person2=

SET /P person3=

SET /P person4=

SET /P person5=

SET /P person6=

SET /P person7=

SET /P person8=

SET /P person9=

SET /P person1=

SET /P person10=

SET /P person11=

SET /P person12=

SET /P person13=

SET /P person14=

SET /P person15=



)

del save1.txt

if "%check%" = 1 (

GOTO AddUser1

)

) else (

if "%check%" = 2 (

GOTO Favorite2



)

1 个答案:

答案 0 :(得分:1)

AFAIK,批处理脚本中没有else if的方法,并且嵌套每个连续IF的方式似乎在许多地方都缺少右括号。我相信你收到的错误很大程度上是由于在启动新命令之前没有关闭命令的丢失包围。当您的IF命令行成功时,总会有GOTO,因此在下面连续IF不应更改批处理文件的预期流量。

@ECHO off
COLOR 0a
@ECHO Intitializing......
@ECHO Done loading! (0.0026s) To continue,
PAUSE
CD C:\Users\Harry\Desktop\Everything
TREE
GOTO Startup

:Startup
CLS
SET /P Answer=Do you want to watch your favorite twitch users?(1) Or enter a custom user?(2) Or add a user to your favorites(3)
REM this may be an easier way to deal with the options when only a single GOTO is run
IF "%Answer%" == "1" GOTO Favorite
IF "%Answer%" == "2" GOTO Questions
IF "%Answer%" == "3" GOTO AddUser
@ECHO *facepalm*
GOTO Startup

:Questions
CLS
SET /P User=Who do you want? (Enter twitch user you want to watch): 
SET /P Quality=What quality do you want? (low/medium/high/source(highest)/audio/mobile(lowest))
SET /P Verify=So you want to watch %User% at %Quality% quality? (yes/no): 
IF "%Verify%" == "yes" (
    GOTO Stream
)
IF "%Verify%" == "no" (
    GOTO Questions
)
@ECHO *facepalm*
GOTO Questions

:Stream
CLS
livestreamer twitch.tv/%User% %Quality%
GOTO Questions

:AddUser
IF EXIST {save1.txt} (
    SET check = 4
    GOTO Load
)
SET numb=0
GOTO AddUser1

:AddUser1
SET person%numb% = ""
SET /P User=Please enter the user: (Enter twitch user you want to add):
%User% = %person%%numb%
SET check = 1
GOTO Save

:Favorite
IF EXIST {save1.txt} (
    SET check = 3
    GOTO Load
)
SET numb=0
SET check = 2

:Favorite1
CLS
GOTO Save

:Favorite2

:Save
@ECHO %numb% > save1.txt
@ECHO %person%numb%% > save.txt
IF "%check%" = 4 (
    GOTO Startup
)
IF "%check%" = 3 (
    GOTO Favorite1
)

:load
< save1.txt (
    SET /P numb=
)

< save.txt (
    SET /P person1=
    SET /P person2=
    SET /P person3=
    SET /P person4=
    SET /P person5=
    SET /P person6=
    SET /P person7=
    SET /P person8=
    SET /P person9=
    SET /P person1=
    SET /P person10=
    SET /P person11=
    SET /P person12=
    SET /P person13=
    SET /P person14=
    SET /P person15=
)

DEL save1.txt

IF "%check%" = 1 (
    GOTO AddUser1
)

IF "%check%" = 2 (
    GOTO Favorite2
)

我可能没有把一切都搞定但是确实运行了,所以可以进行进一步的调试。以下文章可能对您有用 - BAT/CMD Commands