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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Desktop Shortcut

Status
Not open for further replies.

Nebid

Technical User
Jul 29, 2010
2
AU
Hi,

I've been using a vb script (which I found on the internet) to put shortcuts on users desktops (xp) for several years now .

Intermittently, the user gets an error that the shortcut cannot be saved. (not a permission problem)

I am about to do a new server deployment and thought it would be a good idea to address it (it was only ever an annoyance).

To address this I am looking at getting the script to check if the shortcut is already created and delete it and recreate it if it is.

The first problem I am having is combining a special folder path with a string. I suspect I'll have issues with the IF statement after I get past that hurdle...

My script...

Dim Shell, DesktopPath, URL
Set Shell = CreateObject("WScript.Shell")
DesktopPath = Shell.SpecialFolders("Desktop")
Set URL = Shell.CreateShortcut(DesktopPath & "\Scootle.LNK")

' Combine file path
FilePath.CombinePath(DesktopPath & "\Scootle.LNK")

If URL.FileExists(FilePath) then
URL.DeleteFile FilePath, True
Set URL = Shell.CreateShortcut(DesktopPath & "\Scootle.LNK")
URL.TargetPath = " URL.IconLocation = "\\server\netlogon\icons\scootle.ico"
URL.Save
Else
Set URL = Shell.CreateShortcut(DesktopPath & "\Scootle.LNK")
URL.TargetPath = " URL.IconLocation = "\\server\netlogon\icons\scootle.ico"
URL.Save
End If

Quite clearly I have no idea what I am doing! Any help would be appreciated!

Thanks.
 
Unless of course someone knows why a vbs script called by an Active Directory batch file login script sometimes fails for a non-local admin user...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top