Disease Posted March 6, 2009 Posted March 6, 2009 I am trying to auto install an icon on user desktops for an exe using a network path. I have 2 problems: 1. Throws up an error saying unable to save shortcut 2. it puts quotes around the target path and the shortcut then does not work. If I manually edit the shortcut and take the quotes out the link works with the quotes in it does not Any ideas? Copy of of the code I have written is below Thanks. set Shell = CreateObject("WScript.Shell") DesktopPath = Shell.SpecialFolders("AllUsersDesktop") set Link = Shell.CreateShortcut(DesktopPath & "\Testbase KS3 Mathematics.lnk") Link.TargetPath = "\\10.xx.xx.xx\Testbase32\Testbase32.exe K3_MATHS" Link.Save
Michael Posted March 6, 2009 Posted March 6, 2009 You should change the \\10.xx.xx.xx with \\SERVERNAME
Disease Posted March 6, 2009 Author Posted March 6, 2009 Tried that at the time, the problem is not with the path description, its that the script adds the quotes in the target path, which causes the shortcut not to work. "\\whatever\whatever" wont work \\whatever\whatever works
Ric_ Posted March 6, 2009 Posted March 6, 2009 Would it not be easier to create the shortcut on your machine and save it in a shared location... the script could then just copy it from there at logon. 1
Disease Posted March 6, 2009 Author Posted March 6, 2009 (edited) Thanks Ric, working now Edited March 6, 2009 by Disease
SYNACK Posted March 6, 2009 Posted March 6, 2009 (edited) Here is a function that I wrote to do this on my networks. Reusable so you can call the function multiple times to add multiple links. DesktopPath = WshShell.SpecialFolders("Desktop") AddLink "MUSAC Classroom Manager Administrator", "MUSAC Classroom Manager Administrator", "m:\cm\cmadmin.exe", 1, "m:\cm", "", "" Sub AddLink(LinkName, Description, Path, WindowStyle, WorkingDir, Arguments, IconPath) on error resume next Dim link Set link = WshShell.CreateShortcut(DesktopPath & "\" & LinkName & ".lnk") link.Description = Description link.TargetPath = Path link.WindowStyle = WindowStyle link.WorkingDirectory = WorkingDir if (Arguments <> "") then link.Arguments = Arguments if (IconPath <> "") then link.IconLocation = IconPath link.Save link = empty on error goto 0 End Sub your code is giving you an error as you are trying to save to the allusers desktop which you need admin permissions for. Edited March 6, 2009 by SYNACK
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now