Help changing icons

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mwarren
Posts: 5
Joined: 11 Jan 2019 14:25

Help changing icons

#1 Post by mwarren » 11 Jan 2019 14:29

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%
Last edited by aGerman on 11 Jan 2019 16:44, edited 2 times in total.
Reason: code formatting added, real link removed

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Help changing icons

#2 Post by aGerman » 11 Jan 2019 16:45

Works for me as soon as the path specified for IconLocation points to an existing .ICO file.

Steffen

mwarren
Posts: 5
Joined: 11 Jan 2019 14:25

Re: Help changing icons

#3 Post by mwarren » 14 Jan 2019 07:54

It doesn't load the icon I need. The icon it places on the desktop is solid white no details.

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Help changing icons

#4 Post by aGerman » 14 Jan 2019 10:32

I believe you but yet I can't help out as long as I'm not even able to reproduce the failure.

Steffen

mwarren
Posts: 5
Joined: 11 Jan 2019 14:25

Re: Help changing icons

#5 Post by mwarren » 14 Jan 2019 14:05

So it places the icon on the desktop with the correct graphic not just solid white?

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Help changing icons

#6 Post by aGerman » 14 Jan 2019 14:23

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.

mwarren
Posts: 5
Joined: 11 Jan 2019 14:25

Re: Help changing icons

#7 Post by mwarren » 14 Jan 2019 14:26

So for me to give the shortcut a graphic what must I do?

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Help changing icons

#8 Post by aGerman » 14 Jan 2019 14:30

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.

mwarren
Posts: 5
Joined: 11 Jan 2019 14:25

Re: Help changing icons

#9 Post by mwarren » 14 Jan 2019 15:45

Yes, that file does exist

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Help changing icons

#10 Post by aGerman » 14 Jan 2019 16:41

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.

Post Reply