New-Shortcut icon not being embedded in shortcut

Hey all.

I’m trying to create a web shortcut with an icon, and this is what I’m using:

New-Shortcut -Path “$env:ProgramData\Microsoft\Windows\Start Menu\WebShortcutName.url” -TargetPath “https://www.google.com/” -IconLocation “$dirFiles\favicon.ico” -WindowStyle Minimized

I’ve got the .ico file directly in the Files directory. When the shortcut gets created in the Start Menu, though, it doesn’t have the same icon as before… it has the default IE shortcut one. Do custom icons not work for web (.url) shortcuts?

The parameter name is -IconLocation not -Icon and -IconIndex if you need to specify index of icon within the file, otherwise 0 is the default index.

1 Like

got a similar issue, My icon file just doesn’t apply, here’s my code:

New-Shortcut -Path “C:\Users\Public\Desktop\my.url” -TargetPath “https://myweb” -IconLocation “$dirFiles\my.ico”

I am sorry that this is a late reply!

If you reference $dirFiles when creating the shortcut, that folder needs to be present for the lifetime of the shortcut.
If the folder that contains the toolkit is removed after the installation is done, the ico-file is lost and it will not be displayed when viewing the shortcut.