批量设置关闭临时变量

时间:2016-07-02 21:35:34

标签: batch-file

我尝试在回复用户的时间之后制作一个.bat文件以关闭电脑,但不能正常工作:

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:

[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/BuildConfig.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/MainActivity.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/R.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/R$attr.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/R$dimen.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/R$id.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/R$layout.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/R$menu.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/R$mipmap.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/R$string.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/R$style.class

[2016-07-03 02:40:59 - Test1] Dx 11 errors; aborting
[2016-07-03 02:40:59 - Test1] Conversion to Dalvik format failed with error 1

什么都没发生(我以管理员权限运行)

怎么了?

1 个答案:

答案 0 :(得分:1)

怎么了?

SET /P /A temp_var=set time to shutdown:

您不能同时将/p/aset同时使用。选择其中之一。

Syntax
      SET variable
      SET variable=string
      SET /A "variable=expression"
      SET "variable="
      SET /P variable=[promptString]
      SET "

来源set

在您的情况下,您似乎只需要使用set /p

start "" shutdown -s -f -t %temp_var

批处理文件中的变量名称在每端都以%分隔。

  

变量双方都有百分号:%ThisIsAVariable%

来源environment variables

%temp_var替换为%temp_var%

更正了批处理文件:

SET /P temp_var=set time to shutdown:
start "" shutdown -s -f -t %temp_var%
exit

进一步阅读

  • An A-Z Index of the Windows CMD command line - 与Windows cmd相关的所有内容的绝佳参考。
  • environment variables - 环境变量主要在批处理文件中使用,可以使用SET命令为会话创建,修改和删除它们。
  • set - 显示,设置或删除CMD环境变量。使用SET进行的更改将仅在当前CMD会话期间保留。