/build/static/layout/Breadcrumb_cap_w.png

Delete folders without a script?

I've had a problem bugging me for quite a while now and I've been unable to find a good solution. I'm looking for something like this: someutility.exe C:\Windows\Temp\*.* /q This would delete everything in the temp folder silently but NOT touch the temp folder itself. So no rd command. And my ultimate would be a way to delete the Microsoft patch uninstall folders in the Windows directory that start with a "$"... I'd even consider a script for that one. There just doesn't seem to be an easy way to delete folders in windows using a wildcard. Anyone have ideas on this one? I need to do some cleanup before distributing an in-house package.

0 Comments   [ + ] Show comments

Answers (1)

Posted by: jamsek19 16 years ago
Orange Senior Belt
0
You can remove files using VBS script. An example (from VBS help)
[font="courier new"]Sub DeleteAFile(filespec, force)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile filespec, force
End Sub
filespec should have wildcards, therefore to remove everything from c:\Windows\temp folder you call this function this way:
Add a new custom action (VBS script stored in binary data or as a property) called CleanUp:

[font="courier new"]Function CleanUp()
DeleteAFile "c:\Windows\temp\*.*", true
CleanUp = 1 ' means success
End Function

Sub DeleteAFile(filespec, force)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile filespec, force
End Sub



BR
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ