0

我正在尝试做一个批处理脚本,它将成为关闭脚本的开/关开关。

基本上是通过重命名来打开和关闭按任务计划运行的关闭脚本。因此,我有两种选择,一种将其从原始名称重命名为其他名称以停止任务计划触发,另一种通过将名称更改为原始名称将其重新打开。

现在,这工作一次,但如果我尝试再做一次,什么也没有发生。

我哪里错了?

:选项1

rename C:\Users\user\Desktop\shutdown.bat shutdown1.bat 

:选项2

rename C:\Users\user\Desktop\shutdown1.bat shutdown.bat
4

2 回答 2

0

你不应该发布你的代码作为答案......

问题是您没有在选择:Selection2时跳过。Selection1你必须放在GOTO :Quit前面:Selection2

于 2013-08-14T08:30:34.570 回答
0

这是整个代码

@ECHO OFF
C:
CD\
CLS

:MENU
CLS

ECHO ============= MENU NAME =============
ECHO Select an option from below by typing the corresponding number.
ECHO _
ECHO 1.  Turn ON Auto Night Shutdown
ECHO 2.  Turn OFF Auto Night Shutdown
ECHO -------------------------------------
ECHO ==========PRESS 'Q' TO QUIT==========
ECHO.

SET INPUT=
SET /P INPUT=Please select a number:

IF /I '%INPUT%'=='1' GOTO Selection1
IF /I '%INPUT%'=='2' GOTO Selection2
IF /I '%INPUT%'=='Q' GOTO Quit

CLS

ECHO ============INVALID INPUT============
ECHO -------------------------------------
ECHO Please select a number from the Main
echo Menu [1-2] or select 'Q' to quit.
ECHO -------------------------------------
ECHO ======PRESS ANY KEY TO CONTINUE======

PAUSE > NUL
GOTO MENU

:Selection1

rename C:\Users\user\Desktop\shutdown.bat shutdown1.bat 

 :Selection2

rename C:\Users\user\Desktop\shutdown1.bat shutdown.bat

 :Quit
  CLS

  ECHO ==============SUCCESS===============
  ECHO -------------------------------------
  ECHO ======PRESS ANY KEY TO CONTINUE======

  PAUSE>NUL
   EXIT
于 2013-08-14T09:16:59.097 回答