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)
Please log in to answer
Posted by:
jamsek19
16 years ago
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
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile filespec, force
End Sub
Add a new custom action (VBS script stored in binary data or as a property) called CleanUp:
[font="courier new"]
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.
so that the conversation will remain readable.