Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9259025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:33:22+00:00 2026-06-18T12:33:22+00:00

How to set the Icon path of a file or shortcut to a path

  • 0

How to set the Icon path of a file or shortcut to a path containing a dynamic environment variable, in particular the current directory %cd%.

The problem is to set a custom (non-system) icon for a file and that icon remains used on other computers. Both the file and the icon would be shipped in a .zip. When the .zip is uncompressed on other computers, the file should be displayed with the custom icon.

I’m stuck because Windows needs an absolute path and this path changes when the .zip is uncompressed on another computer (with a different absolute location).

I’ve tried, without success, through the GUI Properties window or with PowerShell scripts like

$wshshell = New-Object -ComObject WScript.Shell
$lnk = $wshshell.CreateShortcut("c:\TheFolder\ASubFolder\nameOfMyShortcut.lnk")
$lnk.TargetPath = "%windir%\system32\cmd.exe /c start \"\" \"Includes\myApplication.exe\""

$lnk.IconLocation = "%cd%\Includes\myApplication.ico"
#$lnk.IconLocation = ".\Includes\myApplication.ico"

$lnk.Save()

You can that there’s a trick to make the TargetPath unsensitive to the absolute location of the package folder.

The question is about the how to set the IconLocation path variable relative, both tentatives doesn’t work:

$lnk.IconLocation = ".\Includes\myApplication.ico"

or

$lnk.IconLocation = "%cd%\Includes\myApplication.ico"

As I understand, the environment variable %cd% is dynamical, Windows does not like it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:33:24+00:00Added an answer on June 18, 2026 at 12:33 pm

    The way the problem was solved is the following: Create launcher with C# (or a static binary) that do not requires shipping dll in the root folder of the package. The launcher starts the dynamic binary .exe that is located in the resource folder.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Linux, can one set a custom icon for a folder/directory as it appears
Is there a way to set relative path to the icon in win shortcut?
I am trying to load an icon from a path and set it as
I have try to set icon for my App in the xCode. In the
I just found an icon set here: http://www.archetype-inc.com/yard/fundamentals/icons/ I've been looking for something like
Is there a way to set app icon only based by name. For example
I need to set the default icon that VS uses for the project to
I am trying to set an application icon (python3 / tkinter) like this: Interface()
How do I set a little icon next to the website title on tabs
First I made an app and I set its application icon to a icon

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.