Q: Windows batch file issue setting custom url file icon I am creating a url shortcut with a batch script, but for some reason it doesn't set the icon i tell it to set...
Code:
echo [InternetShortcut]> "C:\winapps\SysNetworkManager.url"
echo URL="C:\winapps\snmres\winstart.bat">> "C:\winapps\SysNetworkManager.url"
echo IconFile="C:\winapps\snmres\snmico.ico">> "C:\winapps\SysNetworkManager.url"
echo IconIndex=0>> "C:\winapps\SysNetworkManager.url"

It doesn't set the icon as C:\winapps\snmres\snmico.ico, instead it sets this icon: C:\Windows\system32\url.dll

A: Try creating a temp VBS
@echo off

set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"

echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "%USERPROFILE%\Desktop\myshortcut.lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "D:\myfile.extension" >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
echo oLink.IconLocation = "C:\myicon.extension" >> %SCRIPT%

cscript /nologo %SCRIPT%
del %SCRIPT%`

