如何确定“您确定"?在Windows批处理文件中提示? [英] How can I make an "are you sure" prompt in a Windows batchfile?

查看:143
本文介绍了如何确定“您确定"?在Windows批处理文件中提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个批处理文件,该文件可以自动将一堆文件从一个地方复制到另一个地方,然后自动备份.唯一有帮助的是,我不小心从命令缓冲区中选择了该命令,并大量覆盖了未提交的更改.

I have a batch file that automates copying a bunch of files from one place to the other and back for me. Only thing is as much as it helps me I keep accidentally selecting that command off my command buffer and mass overwriting uncommited changes.

我的.bat文件需要什么代码才能显示您确定",并在运行文件的其余部分之前键入"y"?如果键入的不是"y",则应在该行退出执行.

What code would I need for my .bat file to make it say "are you sure", and make me type "y" before it ran the rest of the file? If anything but "y" is typed it should exit execution on that line.

修改 11月27日 好的,我再次将其标记为未回答,因为我仍然无法弄清.当我称出口"时它关闭了cmd.exe,这不是我想要的.所有这些都是因为Windows实现的命令缓冲区错误[至少与我以前习惯的不同]

Edit Nov 27 Ok I marked this unanswered again because I still can't figure it out. When I call "exit;" it closes cmd.exe which is not what I want. All this because Windows implemented command buffer wrong [differently than what I am used to at least]

推荐答案

您想要类似的东西

@echo off
setlocal
:PROMPT
SET /P AREYOUSURE=Are you sure (Y/[N])?
IF /I "%AREYOUSURE%" NEQ "Y" GOTO END

echo ... rest of file ...


:END
endlocal

这篇关于如何确定“您确定"?在Windows批处理文件中提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆