Delete shortcut from a network location

Posted on 2008-10-16
Last Modified: 2012-05-05
I have a script that will create a shortcut for me and delete one that is local to a users profile. The problem i'm having is this is in a citrix enviorment that. The uses desktop is redirect to a network share. so the shortcut is located at


what i would like to do is replace the first part of the code to delete the lnk from

i'm really not sure how to do this since i'm really not a scripting guy. any help will be greatfully appricated.
On Error Resume Next

SET fso = Wscript.CreateObject("Scripting.FileSystemObject")

SET WshShell = WScript.CreateObject("WScript.Shell")

strFavs = WshShell.SpecialFolders("Desktop")

Set oFiles = fso.GetFolder(strFavs)

For Each oFile In oFiles.Files

    If lcase(oFile.Name) = "Microsoft Office Outlook 2003.lnk" Then

        oFile.Delete True

    End If


set WshShell = WScript.CreateObject("WScript.Shell")

strDesktop = WshShell.SpecialFolders("Desktop")

set oShellLink = WshShell.CreateShortcut(strDesktop _

  & "\Microsoft Outlook 2007.lnk")

oShellLink.TargetPath = _

  "N:\Program Files\Microsoft Office\OFFICE12\outlook.EXE"

oShellLink.WindowStyle = 1

oShellLink.Hotkey = "CTRL+SHIFT+F"

oShellLink.IconLocation = _

  "N:\Program Files\Microsoft Office\OFFICE12\outloo.EXE, 0"

oShellLink.Description = "Outlook 2007 Shortcut"

oShellLink.WorkingDirectory = strDesktop


Open in new window

Question by:mystics7
LVL 38

Accepted Solution

Shift-3 earned 500 total points
ID: 22732233
This should do it.

strUserName = WshShell.ExpandEnvironmentStrings("%username%")

strFile = "\\server\users$\" & strUserName & "\desktop\Microsoft Office Outlook 2003.lnk"

If fso.FileExists(strFile) Then

    fso.DeleteFile strFile, True

End If

Open in new window


Author Closing Comment

ID: 31506778
Thank you very much that is exactly what I need!!!!!!!

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now