批处理文件以执行启动,运行,%TEMP%和全部删除 [英] Batch file to perform start, run, %TEMP% and delete all

查看:285
本文介绍了批处理文件以执行启动,运行,%TEMP%和全部删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找一种执行以下操作的方法:

looking for a way to perform the following:

开始>运行>%TEMP%>删除所有内容(跳过任何冲突).

Start > Run > "%TEMP% > Delete everything (skipping any conflicts).

到目前为止我有

@echo off
start %TEMP%
DEL *.*

我想我可以使用CD来访问该文件夹,我想知道的是,是否存在无法删除对话框的实例,我想跳过这些对话框.

I suppose I could use CD to get to the folder, the thing I'm wondering is if there are any instances where it cannot delete an a dialog box comes up, I want to skip these.

感谢您的帮助! 利亚姆

Thanks for the help! Liam

推荐答案

del不会触发任何对话框或消息框.但是,您有一些问题:

del won't trigger any dialogs or message boxes. You have a few problems, though:

  1. start只会打开资源管理器,这将毫无用处.您需要cd更改批处理文件的工作目录(/D在那里,因此从其他驱动器运行时也可以使用):

  1. start will just open Explorer which would be useless. You need cd to change the working directory of your batch file (the /D is there so it also works when run from a different drive):

cd /D %temp%

  • 您可能还希望删除目录:

  • You may want to delete directories as well:

    for /d %%D in (*) do rd /s /q "%%D"
    

  • 您还需要跳过del的问题,并删除只读文件:

  • You need to skip the question for del and remove read-only files too:

    del /f /q *
    

  • 所以您到达了:

    @echo off
    cd /D %temp%
    for /d %%D in (*) do rd /s /q "%%D"
    del /f /q *
    

    这篇关于批处理文件以执行启动,运行,%TEMP%和全部删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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