Delete link file using special folders name and .VBS

1,050 pts.
Tags:
LINKS
script
shortcut
VBS
We have a db application that has two databases. One is "test" one is live. It has two different icons. The users train in test and then after traning, they go "live" I have a shortcut that is on "all users" desktop. It runs at user login and they are local admins, because the app needs those rights for the user to be able to run the program. I need to alter the script below so that it will run even if the user is an not an admin, and check for the strDesktop .lnk file, delete it and replace it with another. I just dont understand how to specify that user specific desktop location for deletion. My old script runs fine if the user is an admin, they cant get to the all users desktop, even as a login script. The script as it is now will delete the current all users desktop icon and create the new shortcut based on the logged in user and place that on their desktop. How can i alter it so it will then delete that icon an replace it with another when they need to get the "live" icon? 'this will copy the vantage icon to a users desktop 'that is not an admin or have admin rights 'also will remove all users icon link and replace will user specific link dim FSO, WshShell, strDesktop, sSourceFile Set WshShell = WScript.CreateObject("WScript.Shell") Set FSO =CreateObject("scripting.FileSystemObject") strDesktop = WshShell.SpecialFolders("Desktop") sSourceFile="c:documents and settingsall usersdesktopTest.lnk" If FSO.FileExists(sSourceFile) Then         FSO.DeleteFile sSourceFile else FSO.CopyFile "\tritonInstallVantage Icons.lnk", strDesktop  & "" ====================== need to have delete syntax that will check for the strDesktop .lnk file and delete it with the live one end if set FSO = Nothing set WshShell = Nothing

Software/Hardware used:
xp pro, vb, server 2003
ASKED: October 20, 2010  8:18 PM
UPDATED: April 20, 2011  2:15 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

I’m not sure if I understand the question correctly, but, how about this ?

<pre>FSO.DeleteFile(strDesktop & “\test.lnk”)</pre>

This line will delete the shortcut from the logged in user’s desktop.

If this is not what you mean, or you want to clarify something, please add your comments in the discussion area (below).

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • swinehart6803
    So simple, and worked like a charm! Thank you. My mistake was trying to specify the entire file path to the link rather than just pointing to the desktop and then the link. This works great and you just have to flip the copy delete .lnk files paths to go from live to test. Setup as login and away you go. Great because I have 10 users going live Monday on error resume next dim FSO, WshShell, strDesktop, sSourceFile Set WshShell = WScript.CreateObject("WScript.Shell") Set FSO =CreateObject("scripting.FileSystemObject") strDesktop = WshShell.SpecialFolders("Desktop") sSourceFile1="c:documents and settingsall usersdesktopTest.lnk" If FSO.FileExists(sSourceFile) Then FSO.DeleteFile sSourceFile else FSO.DeleteFile(strDesktop & "Test.lnk") FSO.CopyFile "\serverinstallapplive.lnk", strDesktop & "" end if set FSO = Nothing set WshShell = Nothing
    1,050 pointsBadges:
    report
  • swinehart6803
    Just giving you thanks again. I used this bit of code again to remove a bunch of legacy links.
    1,050 pointsBadges:
    report
  • carlosdl
    I'm glad it's been helpful. Thanks for the feedback.
    65,110 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following