启动时删除临时文件

发布于 2024-09-29 02:59:16 字数 173 浏览 6 评论 0原文

我有一个程序,当它运行时,它会在 Temp 文件夹中填充大量 .tmp 文件。这导致 C 盘被填满。我被要求调查是否可以在 dos 中编写一个脚本来在启动时删除临时文件。我还希望延迟程序启动,直到所有文件都被删除。每次启动时都需要执行此操作。如果可以通过闪存驱动器安装那就太好了。 如果有任何关于如何做到这一点的指示,我将不胜感激

I have a program which when it runs it fills Temp folder with lots of .tmp files. This is causing C drive to fill up. I have been asked to investigate if it's possible to write a script in dos to delete temporary files on startup. I also wish to delay the program starting until all files are deleted. This would need to happen every time on start-up. It would be great if this could be installed via a flash drive.
I would be grateful on any pointers on how this could be done

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

凡尘雨 2024-10-06 02:59:16

我用来删除临时文件的小批量:

@echo off
rd %temp% /s /q
md %temp%
cls
echo Temporary Files have been deleted!
echo.
pause

%temp% 是一个始终会导致当前临时文件夹的路径。但请注意,还有更多临时文件位置,例如 C:\Windows\temp。
如果您只想删除 TMP 文件,请使用 del C:\\*.tmp

The little batch I am using to delete my temporary files:

@echo off
rd %temp% /s /q
md %temp%
cls
echo Temporary Files have been deleted!
echo.
pause

%temp% is a path which always results in your current temporary folder. However note that there are more temporary file locations like C:\Windows\temp.
If you just want to delete TMP files, go with del C:\<MyPath>\*.tmp.

浅紫色的梦幻 2024-10-06 02:59:16

可能还有更复杂的方法,但老式的 del c:\Temp\*.* 应该是一个好的开始。

这里有所有选项的列表:http://www.computerhope.com/delhlp.htm
您可能需要 /F(只读删除)、/S(子目录)和 /Q(安静)

There are probably more sophisticated ways, but the good old fashioned del c:\Temp\*.* should be a good start.

There's a list of all the options, here: http://www.computerhope.com/delhlp.htm
You will probably want /F (delete read only), /S (sub-directories) and /Q (quiet)

戒ㄋ 2024-10-06 02:59:16

我认为 c:\autoexec.bat 文件中的以下行可能有所帮助:

del c:\path\to\temp\files\*.tmp

I assume, the following row in c:\autoexec.bat file may help:

del c:\path\to\temp\files\*.tmp
宫墨修音 2024-10-06 02:59:16

为回复干杯。这就是我正在使用的,

c:
cd \
cd "c:\Documents and Settings\user\Local Settings\Temp\"
del *.tmp /f/s/q
echo All tmp files deleted.
pause

这似乎可以实现我想要的功能。现在我需要它在每次电脑启动时执行此操作。有没有办法通过闪存驱动器安装这个?即编写包含所有命令的批处理文件,放在闪存驱动器上。双击 .bat 文件,现在已安装并将在启动时运行? (有多台需要相同东西的电脑)

Cheers for replies. This is what I'm using

c:
cd \
cd "c:\Documents and Settings\user\Local Settings\Temp\"
del *.tmp /f/s/q
echo All tmp files deleted.
pause

This seems to do what I want it to do. Now I need it to do this everytime PC starts up. Is there a way to install this via flash drive? ie write a batch file with all commands, put on flash drive. double click .bat file, now installed and will run on startup? (Have a number of PCs which need same thing)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文