Jump to content

Recommended Posts

Posted

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

Posted

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

Posted
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.
  • Thanks 1
Posted (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 by SYNACK

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...