Page 1 of 1

Help changing icons

Posted: 11 Jan 2019 14:29
by mwarren
I built this batch file to create a shortcut on the desktop the the icon comes up white and I can't for the life of me figure out how to add to the coding to change the icon to something else rather than white and blank.

Code: Select all

@echo off

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

echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "%USERPROFILE%\Desktop\CUREMD.lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "https://somedomain.com/datlogin.asp" >> %SCRIPT%
echo olink.IconLocation = "C:\Users\Michael Warren\Desktop\CUREMD.ICO"  >> %SCRIPT%
echo oLink.Save >> %SCRIPT%

cscript /logo %SCRIPT%
del %SCRIPT%

Re: Help changing icons

Posted: 11 Jan 2019 16:45
by aGerman
Works for me as soon as the path specified for IconLocation points to an existing .ICO file.

Steffen

Re: Help changing icons

Posted: 14 Jan 2019 07:54
by mwarren
It doesn't load the icon I need. The icon it places on the desktop is solid white no details.

Re: Help changing icons

Posted: 14 Jan 2019 10:32
by aGerman
I believe you but yet I can't help out as long as I'm not even able to reproduce the failure.

Steffen

Re: Help changing icons

Posted: 14 Jan 2019 14:05
by mwarren
So it places the icon on the desktop with the correct graphic not just solid white?

Re: Help changing icons

Posted: 14 Jan 2019 14:23
by aGerman
As I already said CUREMD.ICO must exist on your desktop. Icon pictograms are not included in shortcuts. The shortcut only links an .ICO file (or an icon that exists as resource in executable files or library files). Once CUREMD.ICO doesn't exist in the specified path anymore, also the shortcut doesn't find it anymore and may show up solid white. Do not mix up desktop shortcuts (also known as desktop icons) and .ICO files that contain the image or pictogram which is displayed.

Re: Help changing icons

Posted: 14 Jan 2019 14:26
by mwarren
So for me to give the shortcut a graphic what must I do?

Re: Help changing icons

Posted: 14 Jan 2019 14:30
by aGerman
Sorry but I have no idea what I did wrong with my explanation. I really thought I was clear enough.
mwarren wrote:
11 Jan 2019 14:29
"C:\Users\Michael Warren\Desktop\CUREMD.ICO"
Does this file exist? If it does not exist then you're out of luck.

Re: Help changing icons

Posted: 14 Jan 2019 15:45
by mwarren
Yes, that file does exist

Re: Help changing icons

Posted: 14 Jan 2019 16:41
by aGerman
Okay. So if you have this file on your desktop and it is a valid ICO file then it should already show up with the pictogram that your shortcut shall get later on. If you don't see the pictogram then the file may have extension .ICO but isn't a valid icon file. Another validation is the magic number. That is, if you open the file in a HEX editor then the first four bytes must be 00 00 01 00.