多个文件的批处理文件和 CHOICE 命令
有一个 Windows 程序也可以从上下文菜单中擦除文件和文件夹,即使根本没有确认,然后我创建了一个包含以下内容的批处理文件
@ECHO OFF
CHOICE /M "Do you want to Wipe Files"
IF ERRORLEVEL 2 GOTO QUIT
IF ERRORLEVEL 1 GOTO RUN
:RUN
START "" "C:\Program Files\MyProgram\myexec.exe" /wipe "%~1"
EXIT
:QUIT
EXIT
和一个包含以下条目的注册表项,
[HKEY_CLASSES_ROOT\*\shell\wipefiles\command]
@="\"C:\\Program Files\\MyProgram\\myexec-start.cmd\" \"%1\""
只是为了在擦除文件之前获得安全机会或文件夹,它确实有效。
但是,如果选择了多个文件,那么它会提示您根据文件数量多次回答 Y
或 N
,并且 cmd 窗口保持打开状态,直到您点击所选文件数量的 Y
或 N
次。
有没有办法无论选定的文件有多少,都可以回答一次 Y
或 N
(关闭 cmd 屏幕)?
Having a Windows program that does wipe files and folders from the context menu too even with no confirmation at all then I created a batch file with the following content
@ECHO OFF
CHOICE /M "Do you want to Wipe Files"
IF ERRORLEVEL 2 GOTO QUIT
IF ERRORLEVEL 1 GOTO RUN
:RUN
START "" "C:\Program Files\MyProgram\myexec.exe" /wipe "%~1"
EXIT
:QUIT
EXIT
and a registry key with the following entry
[HKEY_CLASSES_ROOT\*\shell\wipefiles\command]
@="\"C:\\Program Files\\MyProgram\\myexec-start.cmd\" \"%1\""
just to get a safety chance before to wipe the file or the folder and it does work.
However if multiple files are selected then it prompts you to answer Y
or N
for the times as far as the number of files is and furthermore the cmd window remains open until you hit Y
or N
the times as far as the number of selected files is.
Is there a way in order to answer a single time Y
or N
(closing the cmd screen) regardless of the number of selected files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎没有简单的方法可以执行您从上下文菜单中请求的操作,因为会为每个选定的文件打开一个单独的进程。
但可以通过“发送到”菜单轻松完成:
在 SendTo 文件夹中为脚本创建快捷方式,现在您可以发送任意数量的文件或文件夹。
脚本内容如下:
也许这与主题有点偏离,但您可以在 VBScript 中执行此操作,如下所示:
它将显示一个图形消息框,要求用户确认删除,而无需任何终端窗口。
There seems to be no simple way to do what you request from the context menu, since a separate process is opened for each selected file.
But it can be done easily from the send to menu:
Create a shortcut in the SendTo folder for your script, and now you can send as many files or folders as you want.
The script reads as follows:
Maybe it's a bit of a deviation from the theme, but you can do it in VBScript like this:
It will display a graphical message box asking the user to confirm the deletion, without any terminal window.