Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting Url (Special) Links 1

Status
Not open for further replies.

willir

MIS
Aug 5, 2003
2,754
0
0
US
It has been a long, long time since I been to Tek-Tips -- the site is great, just a severe lack of time.

And I am stumped.

I want to delete links to the web sites that Microsoft automatically populates into the end users' favourites when installing Internet Explorer.

* My code works fine for deleting regular files.
* I believe I have the correct and proper names for these special files.
* I can cut and paste the value straight from the variable when running the VB code into a DOS prompt and the file is recognized and deleted.

The issue is that VBA does not seem to recognize that the special URL files exists...
If FSO.FileExists(URLlinkFile.url)

Specifically, I can delete MSN.com.url at the command line, but not within the VBA code.

Code Snipette...
Code:
' Variables correctly initialized above

strRoot = "\\ADserver\UserProfiles\"
strFavourites = "\Favorites"
strMicrosoftLinks = "MSN.com.url Radio Station Guide.url Free Hotmail.url " _
& "Windows Marketplace.url Windows Media.url"

' non relevent code in between

If FSO.GetSpecialFolder(strFolder) Then
                
     strTemp = strMicrosoftLinks
     intZ = Len(strTemp)
     intDeleted = 0
                
     Do While intZ
        'I have used underscore for delimination between files
        intY = InStr(1, strTemp, "_")
                    
        If intY Then
             strFile = strQ & strFolder & "\" & Left(strTemp, intY - 1) & strQ
             strTemp = Mid(strTemp, intY + 1, intZ - intY)
             intZ = Len(strTemp)
        Else
             'End if string
             strFile = strQ & strFolder & "\" & strTemp & strQ
             strTemp = ""
             intZ = 0
        End If
                    
     [b]If FSO.FileExists(strFile) Then[/b]

             ' Same results with either using FSO or command line
             FSO.DeleteFile

             ' Alternate command line approach
             'stCmd = "cmd /c del " & strFile
             'Call Shell(stCmd, 0)
             intDeleted = intDeleted + 1

             ' AND YES, I have also used FSO file extensions to
        End If
                
     Loop
                
     strMsg = strProcessed & intDeleted
        
End If

' More code below

One more thing...
I can take out the FileExist and the FSO.DeleteFile or 'stCmd = "cmd /c del " & strFile works just fine.

Comments or suggestions?

Richard

 
What is the meaning of the following ?
If FSO.GetSpecialFolder(strFolder) Then

Anyway, the FileExists and DeleteFile methods don't like pathname surrounded by double-quotes ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV -- good to hear from you again.

And what do you know -- it worked.

I can understand how ...
strFile = \\ADserver\UserProfiles\User1\Favorites\MSN.com.url
... would work.
and ...

But I was pleasantly surprized that ...
\\ADserver\UserProfiless\User1\Favorites\Radio Station Guide.url
... also worked.

I would not have expected that the spaces in the file name to have worked.

Thank you.
Richard
 
As an fyi,
FSO.GetSpecialFolder(strFolder)
was required to open the Favorites folder
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top