我怎样才能让一个"你确定"在DOS批处理文件提示? [英] How can I make an "are you sure" prompt in a DOS batchfile?

查看:158
本文介绍了我怎样才能让一个"你确定"在DOS批处理文件提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,它可以自动复制一堆文件从一个地方到另一个和回来给我一个批处理文件。唯一的一点是,它更可以帮助我,我一直在无意中选择该命令关闭我的命令缓冲区和覆盖质量未提交更改。

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文件什么code,使其说:你肯定,并让我输入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

这篇关于我怎样才能让一个"你确定"在DOS批处理文件提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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