Solved

Delete shortcut from a network location

Posted on 2008-10-16
2
797 Views
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

\\server\users$\user\desktop.

what i would like to do is replace the first part of the code to delete the lnk from
\\server\users$\%username%\desktop\

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

Next

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

oShellLink.Save

Open in new window

0
Comment
Question by:mystics7
2 Comments
 
LVL 38

Accepted Solution

by:
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

0
 
LVL 9

Author Closing Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to combine txt files and change .txt extension 7 52
How to debug this code 7 56
how to add field in my script 2 31
Command to modify Registry entry 5 98
Unlike scripting languages such as C# where a semi-colon is used to indicate the end of a command, Microsoft's VBScript language relies on line breaks to determine when a command begins and ends. As you can imagine, this quickly results in messy cod…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

895 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

13 Experts available now in Live!

Get 1:1 Help Now