windows - 在 Win7 中使用 .bat 文件休眠。 hibernate 怎么输入y,不 hibernate 怎么输入n?

标签 windows batch-file cmd

我已经为 Windows 7 中的休眠创建了一个 .bat 文件。但是我想用 1 和 2 来使用 n 和 y。但是errorlevel不支持字母。我需要做什么?

@ECHO off
ECHO Press y for hibernate,n for exit
@CHOICE /C:12
IF ERRORLEVEL 2 GOTO two
IF ERRORLEVEL 1 GOTO one
GOTO end
:one
ECHO You have pressed "1"!
GOTO end
:two
ECHO You have pressed "2"!
%windir%\system32\rundll32.exe PowrProf.dll, SetSuspendState 0,1,0
:end
@PAUSE

最佳答案

choice默认是YN,不知道你为什么说做不到。你已经告诉它只做 1 和 2。

阅读帮助。

choice /?

第一个选择1,第二个选择2,...,第n个选择n。

关于windows - 在 Win7 中使用 .bat 文件休眠。 hibernate 怎么输入y,不 hibernate 怎么输入n?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26454305/

相关文章:

windows - MSysGit - 直接运行bat文件

windows - 使用Golang获取Windows认可的环境变量

c++ - 如果我创建了一个进程,是否意味着我总能终止它?

variables - Windows批处理文件: what is variable expansion,和EnableDelayedExpansion是什么意思?

windows - 以提示方式编写但未执行的批处理窗口命令

batch-file - 使用 Batch 列出任何环境 PATH 中的所有可执行文件

linux - 从 Linux 计算机到 Windows 计算机的远程文件传输

c# - 如何使用 Entity Framework 一次将数据插入两个表

windows - 使用不同的进程名称执行批处理文件

bash - 从 PuTTY 运行的 shell 脚本返回代码到调用批处理文件?