/build/static/layout/Breadcrumb_cap_w.png

K1000 Scripting: Changing icon of shortcut via script

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?


2 Comments   [ + ] Show 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. - dugullett 11 years ago
    • This is the easiest way I found. works well - SMal.tmcc 11 years ago
    • 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! - lmland 11 years ago
      • 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 - dugullett 11 years ago
  • Next question... How do I make this run as a specific user (i.e. admin)? - lmland 11 years ago
    • If you create it as an Online Script you will have an option to "Run As". - dugullett 11 years ago

Answers (1)

Answer Summary:
Posted by: drose23 11 years ago
Second Degree Blue Belt
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
 

Comments:
  • This is a vb script correct? So, do you have the first step unzip the icon file and the second step run this script? - lmland 11 years ago
    • What is YMMV? - lmland 11 years ago
      • Your Mileage May Vary. Just stating it's worked well for me. - drose23 11 years ago
    • 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 - drose23 11 years ago
      • Can't say how that would work with a K1000, however. - drose23 11 years ago
  • 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. - lmland 11 years ago
    • Is the Waco, TX I'm assuming? You're not too far from me. - dugullett 11 years ago
      • Yes, I work at Waco ISD on the banks of the Brazos. - lmland 11 years ago
      • Cool. I'm in Dallas. Not really on any banks, but plenty of roads. - dugullett 11 years ago
  • 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 - drose23 11 years ago
    • Although I'd suggest placing the .ico file somewhere besides the desktop. - drose23 11 years ago
  • script works perfect outside of kace. - lmland 11 years ago
    • OK, unfortunately my ability to assist ends here then. Good luck - drose23 11 years ago
  • 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. - lmland 11 years ago
    • 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. - dugullett 11 years ago
  • Ok, next question... does anyone know how to set a script to run as a specific user (i.e. administrator)? - lmland 11 years ago
  • 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? - anonymous_9363 11 years ago
  • You're right. Apologies. I will start a new thread. - lmland 11 years ago

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ