+ Post New Thread
Results 1 to 6 of 6
Scripts Thread, Desktop Icon script problem. in Coding and Web Development; I am trying to auto install an icon on user desktops for an exe using a network path. I have ...
  1. #1
    Disease's Avatar
    Join Date
    Jan 2006
    Posts
    1,099
    Thank Post
    118
    Thanked 70 Times in 48 Posts
    Rep Power
    56

    Desktop Icon script problem.

    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.
    Code:
    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

  2. #2

    Michael's Avatar
    Join Date
    Dec 2005
    Location
    Birmingham
    Posts
    9,262
    Thank Post
    242
    Thanked 1,572 Times in 1,252 Posts
    Rep Power
    340
    You should change the \\10.xx.xx.xx with \\SERVERNAME

  3. #3
    Disease's Avatar
    Join Date
    Jan 2006
    Posts
    1,099
    Thank Post
    118
    Thanked 70 Times in 48 Posts
    Rep Power
    56
    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

  4. #4

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,592
    Thank Post
    109
    Thanked 769 Times in 598 Posts
    Rep Power
    181
    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.

  5. Thanks to Ric_ from:

    Disease (6th March 2009)

  6. #5
    Disease's Avatar
    Join Date
    Jan 2006
    Posts
    1,099
    Thank Post
    118
    Thanked 70 Times in 48 Posts
    Rep Power
    56
    Thanks Ric, working now
    Last edited by Disease; 6th March 2009 at 11:31 AM.

  7. #6

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,186
    Thank Post
    875
    Thanked 2,717 Times in 2,302 Posts
    Blog Entries
    11
    Rep Power
    780
    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.

    Code:
    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.
    Last edited by SYNACK; 6th March 2009 at 12:03 PM.

SHARE:
+ Post New Thread

Similar Threads

  1. Desktop shortcut deployment script
    By contink in forum Scripts
    Replies: 1
    Last Post: 29th May 2009, 07:12 PM
  2. Replies: 4
    Last Post: 20th June 2008, 05:26 PM
  3. Replies: 1
    Last Post: 21st December 2007, 06:27 PM
  4. Adding an Icon to RM CC3 Desktop
    By Mintsoft in forum Windows
    Replies: 4
    Last Post: 10th September 2007, 08:15 AM
  5. Bizarre Taskbar Icon Problem
    By DreddMetal in forum Windows
    Replies: 5
    Last Post: 10th July 2007, 08:48 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •