Discussion:
red admin cmd windows taskbar running programs icon
(too old to reply)
Robin Goodfellow
2021-09-05 15:39:09 UTC
Permalink
How can we colorize any given running-task icon in the taskbar?

I open command windows with the "Run" command (not from a shortcut!).
I don't make shortcuts for something that is only three letters. :)

Some of those are admin windows, but most are user windows.
Each shows up as a "running task" in the taskbar.

But they all look the same in the running tasks icons in the taskbar.

Currently I open a red admin command window using the cmda.bat script
(which is appended to the sig below, and which works beautifully).

But the icon for that red admin command window is indistinguishable from any
other icon in the taskbar for running programs.

How can I change the color of the cmda.bat running icon in the taskbar?
--
@ECHO OFF

REM This is a standalone cmda.bat program
REM It opens a very visible RED command window
REM Open a new shell "Run As Administrator" (cmda.bat)
REM Type "cmda" in a Run window (instead of "cmd")
REM Based on script by foxidrive on alt.msdos.batch

SETLOCAL ENABLEEXTENSIONS

IF NOT "%~1"=="" goto :START

SET LogFile=%TEMP%\cmda.vbs"
Echo Set UAC = CreateObject("Shell.Application") >"%LogFile%"
Echo UAC.ShellExecute "%~f0", "%cd%", "", "runas", 1 >>"%LogFile%"
Start "" /MIN "%LogFile%"
goto :EOF

:START
Cmd /k "CD /D "%*" & Echo Administrator: & color 4F"
:EOF
VanguardLH
2021-09-06 01:53:15 UTC
Permalink
Post by Robin Goodfellow
How can we colorize any given running-task icon in the taskbar?
I open command windows with the "Run" command (not from a shortcut!).
I don't make shortcuts for something that is only three letters. :)
Some of those are admin windows, but most are user windows.
Each shows up as a "running task" in the taskbar.
But they all look the same in the running tasks icons in the taskbar.
Currently I open a red admin command window using the cmda.bat script
(which is appended to the sig below, and which works beautifully).
But the icon for that red admin command window is indistinguishable from any
other icon in the taskbar for running programs.
How can I change the color of the cmda.bat running icon in the taskbar?
The icon shown in the Taskbar is taken from the image resources in the
executable file for the program when you run it (a default one is
specified, but there could be more than 1 image resource). If you are
asking how to make multiple running instances of the program have
different images for their taskbar buttons, you can change the icon in
the shortcut properties.

Right-click on a shortcut -> Shortcut tab -> Change icon

The default is to show you the image resources in the executable file
specified for the shortcut to run. Some programs only have 1 image
resource, and console-mode (DOS) programs often don't have any, so you
pick one. cmd.exe has just 1 image resource, so opening multiple
instances has the 1 image used in each taskbar button.

There are some other files bundled with Windows that provide image
resources, like shell32.dll, and moricons.dll. Any file with an image
resource (.exe, .dll) can be used to specify the icon source; however,
if they for software you install, those image resources disappear when
you uninstall that software.

If you don't like any that are in Windows bundled files, or in
executables you installed, you can also find .ico files online. I did
that for a weather.com icon since the icon resources in Windows didn't
work. While I could try to rely on cached icons (favicon.ico) from a
web site, periodially they seem to disappear, probably if you purge all
locally cached data when exiting the web browser.

As I recall, a shortcut cannot point at a .bat file to run it. That's a
text file that has to get fed into a command interpreter. The shortcut
has to call cmd.exe when then runs the .bat file, as in:

cmd.exe /c <path>\<batfile>
Robin Goodfellow
2021-09-06 02:14:35 UTC
Permalink
Post by VanguardLH
The icon shown in the Taskbar is taken from the image resources in the
executable file for the program when you run it (a default one is
specified, but there could be more than 1 image resource).
Hi Vanguard,
I've written tutorials on assigning icons so I'm aware of where _all_ the
Windows icons are kept (scattered about); but you just gave me a good idea.

Maybe perhaps I can _copy_ the cmd.exe executable and then I might be able
to call one cmd.exe for the user-level command and then call a copy of that
cmd.exe for the admin level command where I would have previously set each
to different icons... (dunno if that will work yet though - need to test)...

a. User level command window "Run > cmd [enter]" ==> black taskbar icon
b. Admin level command window "Run > [shift+alt+enter] ==> red taskbar icon

Maybe I can then set the admin level cmd.exe to show a red icon in the
taskbar while the normal user level cmd.exe would show the black icon.

I'll try that. Thanks for the idea.
Post by VanguardLH
If you are
asking how to make multiple running instances of the program have
different images for their taskbar buttons, you can change the icon in
the shortcut properties.
Right-click on a shortcut -> Shortcut tab -> Change icon
As I said in the OP, I'm not using shortcuts because I generally don't make
shortcuts for a 3-character command (Run > cmd).

Having said that, I'm rather familiar with shortcuts to the scheduled tasks
(yes, I wrote a tutorial on that also) which bypass the UAC prompts.

I _could_ do this with shortcuts, but I was hoping for more elegance, which
usually takes knowledge of how Windows actually works to be successful.
Post by VanguardLH
The default is to show you the image resources in the executable file
specified for the shortcut to run. Some programs only have 1 image
resource, and console-mode (DOS) programs often don't have any, so you
pick one. cmd.exe has just 1 image resource, so opening multiple
instances has the 1 image used in each taskbar button.
As I said in the OP, I'm not using a shortcut for a 3-character command,
but, of course, if that's the _only_ way to do it, I'll stoop that low. :)
Post by VanguardLH
There are some other files bundled with Windows that provide image
resources, like shell32.dll, and moricons.dll. Any file with an image
resource (.exe, .dll) can be used to specify the icon source; however,
if they for software you install, those image resources disappear when
you uninstall that software.
Rest assured, I've located _every_ one as I wrote tutorials on this stuff.
Post by VanguardLH
If you don't like any that are in Windows bundled files, or in
executables you installed, you can also find .ico files online. I did
that for a weather.com icon since the icon resources in Windows didn't
work. While I could try to rely on cached icons (favicon.ico) from a
web site, periodially they seem to disappear, probably if you purge all
locally cached data when exiting the web browser.
I've been making my own icons for years, where, nowadays, with Irfanview
being able to save a transparent bg ico file, it's trivial to create them.
Post by VanguardLH
As I recall, a shortcut cannot point at a .bat file to run it. That's a
text file that has to get fed into a command interpreter. The shortcut
cmd.exe /c <path>\<batfile>
The restrictions between shortcuts to batch versus executable files is
something I habitually deal with on a case-by-case basis, and the ability to
string along "%comspec% -k" (or "%comspec% -c") commands is often used.

I have no problem stringing them together (using the "&&" syntax); but
that's not really what I'm asking here if that, in and of itself, doesn't
end up with the following:
1. When I run cmd as admin, I get a red icon in the taskbar.
2. When I run cmd as a user, I keep the normal black ion in the taskbar.

I'm almost never unsuccessful; I was just hoping someone else who knows
Windows better than I do had already solved this particular problem set.

Thanks. I'll let you know when I'm successful.
Robin Goodfellow
2021-09-06 05:52:40 UTC
Permalink
Post by Robin Goodfellow
Maybe perhaps I can _copy_ the cmd.exe executable and then I might be able
to call one cmd.exe for the user-level command and then call a copy of that
cmd.exe for the admin level command where I would have previously set each
to different icons... (dunno if that will work yet though - need to test)...
Unfortunately, it's a little harder than I thought it would be to _replace_
the existing cmd.exe with one that has red resource icons, so I simply
document below what I tried, which failed, but the idea "may" still be
sound.

The idea is to have _two_ cmd.exe executables (exactly the same in all but
name & icon resources).

1. cmd.exe (original, with default black icon resources)
2. cmda.exe (copy of the original, with new red icon resources)

Here's what I tried (and failed so far) to do, but only because I don't
understand yet how to get past the Windows Trusted Installer permissions!

Resource Hacker 5.1.8
https://www.howtogeek.com/75983/stupid-geek-tricks-how-to-modify-the-icon-of-an-.exe-file/
http://www.angusj.com/resourcehacker/

Name: reshacker_setup.exe
Size: 4176295 bytes (4078 KiB)
SHA256: 080E97F7C198AEEAC2A172F055C09D8DA365B59B58BF6A71BDE4486D9992FF66

1. I right clicked to "Run as Administrator" the Resource Hacker
C:\Program Files (x86)\Resource Hacker\ResourceHacker.exe
2. ResourceHacker:File > Open > C:\Windows\System32\cmd.exe
Select the "Icon" folder > Action > Replace Icon
Press "Open file with new icon"
Browse to any exe, dll, res, or ico file of your choice.
C:\Windows\system32\fontview.exe > Replace > Save

Note: I could have picked _any_ file that had resources,
as later I'll create a custom icon; so any resource will do for now.

3. Drat. I can't overwrite the old cmd.exe in the System32 directory!
You need permission from Trusted Installer to make changes to this file.
https://www.drivereasy.com/knowledge/you-require-permission-from-trustedinstaller-error-fixing-guide/

In summary, my goal was to have _two_ duplicate cmd.exe files, where the
second cmda.exe differed only in name and in icon.

I have a few more ideas to try, but that's what I wanted to document
for now, before I try another approach.
Robin Goodfellow
2021-09-06 06:03:10 UTC
Permalink
Post by Robin Goodfellow
I have a few more ideas to try, but that's what I wanted to document
for now, before I try another approach.
BTW, I should mention I had googled _before_ I had asked, and every one I
found failed, but I have no intention of failing in this Windows task.

1. Change icons of specific cmd windows in Windows 10
https://superuser.com/questions/1254293/change-icons-of-specific-cmd-windows-in-windows-10

2. Changing CMD/BAT icons on task bar
https://answers.microsoft.com/en-us/windows/forum/all/changing-cmdbat-icons-on-task-bar/97323ec1-7fea-4346-802c-18566e93d4a0

3. Way to change icon for individual cmd file?
https://icofx.ro/forum/viewtopic.php?f=3&t=934

What I'll try next is just changing the _copy_ of cmd.exe (instead of
changing the original cmd.exe, which I hadn't known was going to be so well
protected by Windows as I had never tried to change its resources before).

This is basically what I'll try next:
a. Make a copy of cmd.exe
b. Change the icon resources of _that_ copy.
c. Use that modified cmd.exe for the red icon in the task bar

Loading...