I am brand new to scripting. I can create the Kace script to put a URL shortcut on all users desktops, but I need to give it an icon so it isn't just a blank page. I have googled and tried vbs and batch scripts to get it to work and am having zero results. any clues or help?

Answer Summary:
Cancel
2 Comments   [ + ] Show Comments

Comments

  • How are you currently scripting the shortcut? You should be able to create it on a test machine with the icon needed, and ZIP it. Then create a script/MI to push it out.
    • This is the easiest way I found. works well
    • I haven't worked as much on this side of the kace appliance. i mainly configure the HelpDesk and create sql reports.

      I am trying to run it as a script. How would I do it as a MI? I need to create a software asset for the shortcut first? Zip the shortcut and icon file together? Help!
      • Create the shortcut as you need it location and icon. Zip that file. Create a new online script. Select your OS, machine label, and schedule. Under the task section enter something like this. Assuming you want it at "c:\users\Public\desktop".

        Verify: A File Exists
        Directory: c:\users\Public\desktop
        File: shorcut.lnk

        Remediation: Unzip a file
        Directory: $(KACE_DEPENDENCY_DIR)
        File: Name_of_zip.ZIP
        Target: c:\users\Public\desktop
  • This content is currently hidden from public view.
    Reason: Removed by member request
    For more information, visit our FAQ's.
  • Next question... How do I make this run as a specific user (i.e. admin)?
    • If you create it as an Online Script you will have an option to "Run As".
Please log in to comment

Answers

0

YMMV - but here is a script I've used to accomplish this task.

 

 Option Explicit 
 
On Error Resume Next
 
Dim objShell
Dim objDesktop
Dim  objLink
Dim strAppPath
Dim strWorkDir
Dim strIconPath
 
strWorkDir ="C:\windows"
strAppPath = "%PATH TO EXE OR TARGET%" 
strIconPath = "%PATH TO .ICO OR SIMILAR FILE%" 
 
Set objShell = CreateObject("WScript.Shell")
objDesktop = objShell.SpecialFolders("AllUsersDesktop")
Set objLink = objShell.CreateShortcut(objDesktop & "\Shortcut.lnk") 'change here To your shortcut name
 
 
objLink.Description = "Description" 'replaec with your description
objLink.IconLocation = strIconPath 
objLink.TargetPath = strAppPath
objLink.WindowStyle = 3
objLink.WorkingDirectory = strWorkDir
objLink.Save
 
Answered 07/09/2013 by: drose23
Second Degree Blue Belt

  • This is a vb script correct? So, do you have the first step unzip the icon file and the second step run this script?
    • What is YMMV?
      • Your Mileage May Vary. Just stating it's worked well for me.
    • Yes - this script assumes the .ico file already exists at the path. We do our deployments with WISE Scripting, so the file copy would occur outside of the .vbs itself
      • Can't say how that would work with a K1000, however.
  • I cannot get this to work. I've used both methods in this article to call a vb script: http://www.kace.com/support/resources/kb/article/how-to-call-a-visual-basic-script and neither one puts a shortcut on the desktop. Here's the order for the script:

    1. Verify that the file “C:\Users\Public\Desktop\Waco ISD Help Desk.lnk†exists.
    2. Remediation: Unzip “$(KACE_DEPENDENCY_DIR)\helpdesk.zip†to “C:\Users\Public\Desktopâ€. (This is the icon file.)
    3. Run script either as batch file launching cscript.exe or launch program to run the above script modified for my purposes to:

    Option Explicit

    On Error Resume Next

    Dim objShell
    Dim objDesktop
    Dim objLink
    Dim strAppPath
    Dim strWorkDir
    Dim strIconPath

    strWorkDir ="C:\windows"
    strAppPath = "https://helpdesk.wacoisd.org"
    strIconPath = "C:\Users\Public\Desktop\helpdesk.ico"

    Set objShell = CreateObject("WScript.Shell")
    objDesktop = objShell.SpecialFolders("AllUsersDesktop")
    Set objLink = objShell.CreateShortcut(objDesktop & "\Waco ISD Help Desk.lnk")


    objLink.Description = "Waco ISD Help Desk"
    objLink.IconLocation = strIconPath
    objLink.TargetPath = strAppPath
    objLink.WindowStyle = 3
    objLink.WorkingDirectory = strWorkDir
    objLink.Save

    Anyone see what I'm doing wrong? icon file shows up on desktop, but that's it.
    • Is the Waco, TX I'm assuming? You're not too far from me.
      • Yes, I work at Waco ISD on the banks of the Brazos.
      • Cool. I'm in Dallas. Not really on any banks, but plenty of roads.
  • Again not knowing KACE - what happens when you run that VBscript outside of KACE, assuming all pre-requisites exist? Does the icon get created successfully?

    The script itself looks fine to me
    • Although I'd suggest placing the .ico file somewhere besides the desktop.
  • script works perfect outside of kace.
    • OK, unfortunately my ability to assist ends here then. Good luck
  • Figured it out. Needed to run the vb script in the same task as unzipping the icon. Works like a charm now. Still not sure how to do this with a managed install as others suggested. Scripting seems simpler.
    • I added how to use it with scripting in the comments. You can do it though MI, but scripting is better for this. With MIs you would need to create a custom inventory rule, and all of that.
  • Ok, next question... does anyone know how to set a script to run as a specific user (i.e. administrator)?
  • General fora etiquette - not just here - is to not add supplementary questions to a solved problem but rather to create a new thread. That is for your benefit, of course. How will anyone know you asked this new question unless they happen to be reading what is essentially an unrelated question?
  • You're right. Apologies. I will start a new thread.
Please log in to comment
Answer this question or Comment on this question for clarity