Link to home
Create AccountLog in
Programming

Programming

--

Questions

--

Followers

Top Experts

Avatar of sirbounty
sirbounty🇺🇸

Programmatically change Icon for desktop shortcut...
First of all - is this possible?  I know it can be done, but can it be done for each profile if the change is applied to say All Users\Desktop\Shortcut.lnk?

Secondly - any guidance on this.  We're using a product called Netbackup and the default shortcut placed on the desktop points to an invalid icon - I'd like to correct this, but across 90+ servers, I'd rather script a solution...

WSH/WMI/VBS preferred

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of yermejyermej

You'll want to do something like this:

dim strIcon, strCutPath, oShell, oCut

strIcon = "notepad.exe, 0"  ' the correct icon as specified by file name, position in the file
strCutPath = "c:\document & settings\all users\desktop\shorcut.lnk" ' the shortcut you want to change

set oShell = WScript.CreateObject("WScript.Shell")
set oCut = WShell.CreateShortcut(strCutPath)
oCut.IconLocation = strIcon
oCut.Save

Avatar of sirbountysirbounty🇺🇸

ASKER

Any way to have this loop through a list of servers?

Or maybe I can just deploy it locally - I already have code to do that...let me test this...thanx.

Avatar of sirbountysirbounty🇺🇸

ASKER

Using this - I get "unable to save shortcut".  Here's the code:

dim strIcon, strPath
dim oShell, oCut

strIcon="E:\VERITAS\NetBackup\bin\nbconsole.exe, 0"
strPath="%AllUsersProfile%\Desktop\NetBackup Administration Consol (E).lnk"

Set oShell = Wscript.CreateObject("Wscript.Shell")
Set oCut = oShell.CreateShortcut(strPath)

oCut.IconLocation = strIcon
oCut.Save

Set oCut=Nothing
Set oShell=Nothing
 

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of sirbountysirbounty🇺🇸

ASKER

I've also tried using a dll that contains about 7 different icons - still no go... :(
Any ideas?

ASKER CERTIFIED SOLUTION
Avatar of yermejyermej

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

My apologies; I confused my operators.

This line above:
if oFile.attributes & 1 then oFile.attributes = oFile.attributes - 1

should read:
if oFile.attributes and 1 then oFile.attributes = oFile.attributes - 1


Avatar of sirbountysirbounty🇺🇸

ASKER

Part of the problem may have been I'm running this from E: and AllUsersProfile is on C:...
But thanx - it works! :^)

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.

Programming

Programming

--

Questions

--

Followers

Top Experts

Programming includes both the specifics of the language you’re using, like Visual Basic, .NET, Java and others, but also the best practices in user experience and interfaces and the management of projects, version control and development. Other programming topics are related to web and cloud development and system and hardware programming.