启动时删除临时文件
我有一个程序,当它运行时,它会在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我用来删除临时文件的小批量:
%temp% 是一个始终会导致当前临时文件夹的路径。但请注意,还有更多临时文件位置,例如 C:\Windows\temp。
如果您只想删除 TMP 文件,请使用
del C:\\*.tmp
。The little batch I am using to delete my temporary files:
%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
.可能还有更复杂的方法,但老式的
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)
我认为 c:\autoexec.bat 文件中的以下行可能有所帮助:
I assume, the following row in c:\autoexec.bat file may help:
为回复干杯。这就是我正在使用的,
这似乎可以实现我想要的功能。现在我需要它在每次电脑启动时执行此操作。有没有办法通过闪存驱动器安装这个?即编写包含所有命令的批处理文件,放在闪存驱动器上。双击 .bat 文件,现在已安装并将在启动时运行? (有多台需要相同东西的电脑)
Cheers for replies. This is what I'm using
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)