Kill command - with wildcards

Z

zSplash

I have asked this question in an Excel usergroup, getting no solution.
Since KILL is a VB command, perhaps this is the proper forum.

I am trying to eliminate all desktop shortcuts with "log" in their filename.
Here is the code I have unsuccessfully tried:
Kill "C:\Documents and Settings\username\Desktop\*log*.lnk"

Using the same code without wildcards (i.e., if I know the exact name of the
shortcut) works fine. Am I mis-using the wildcards in this Kill? Can
someone please offer guidance?

TIA
 
S

Steve Yandl

Create a reference to the scripting runtime library and create an instance
of "Scripting.FileSystemObject". The folder object contains a collection of
files which you can iterate through using a 'For Each...Next" loop. Use an
If statement with the InStr function to determine which lnk files contain
the string "log" and delete them if that is your choice. I'd probably run
this as a standalone vbs script but if you want this as a subroutine in some
macro you can certainly do it with VBA.

Steve
 
H

Helmut Weber

Hi,
Dim strFile As String
strFile = Dir("c:\windows\desktop\*.doc", vbNormal)
While strFile <> ""
MsgBox strFile ' kill strfile
strFile = Dir
Wend
delete all docs on the desktop, unless
they are opened or protected or whatever.
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top