# Setting the window icon for a command prompt window

1. ## Setting the window icon for a command prompt window

I have a set of scheduled tasks, all of which run programs written in Open Object REXX. Consequently, the Command Prompt windows where these tasks runs inherit their icons (at the top left of the window) from the rexx.exe program that handles my scripts.

This means that all of these REXX tasks display the same icon in the taskbar, or system area, which is unhelpful.

I doubt that there's any way of influencing the icon from my REXX code itself, but is there some sort of wrapper program that I could run, which would allow me to choose different icons for each of the scheduled tasks? Perhaps by running my REXX from some program other than a Command Prompt window?

I'll also go and ask the REXX community, so we'll see who gets there first! :)

I realise that this is something of a long shot, but if I don't ask, I'll never get...
My Computer

2. swiftie said:
[I]s there some sort of wrapper program that I could run, which would allow me to choose different icons for each of the scheduled tasks?
You're asking us how to create a Shortcut.
My Computer

3. Pyprohly said:
You're asking us how to create a Shortcut.
I thought I was asking how to create a shortcut in the Actions tab of the Task Scheduler. I bet this can't be done.

But since that wasn't obvious, is there some way to influence the window icon that you get when a scheduled task results in a Command Prompt window?
My Computer

4. We're talking about these, yes?

You can influence these icons by creating a Shortcut to a program and altering the icon in the Shortcut's properties. Schedule the Shortcut to run and your custom icon will be seen.
My Computer

5. No, that's an ordinary command prompt window. I'm OK tailoring those.

I'm talking about the window that you get when a scheduled task runs an executable that doesn't have a GUI. Then you get this:

Note the icon at the top left. Other than that, it looks exactly like a command prompt window.

Associated with this window, you get one of these in the taskbar (the one with the keys):

Imagine having two or three of these... which one to click?

I've engineered these scheduled tasks to have something meaningful in their title, so I can distinguish them, but I'd prefer distinct icons, if possible.
My Computer

6. It does not matter if we're talking about a command prompt or some Rexx script. Most applications will inherit the icon of a Shortcut file.

Shortcuts are the only way to influence the icon of a program (aside from directly hacking into the executable, ripping it's icon out and replacing it with new one).

I tested with a Python script: made a shortcut to it, changed the icon of the Shortcut; and sure enough, the GUI-less program ran with the icon the Shortcut was set to.

Easy as Py. And you'll find it's easy as Rexx once you try the same.
My Computer

7. OK, you created your shortcut. Now try running it as a scheduled task. If you manage this, and it shows your tailored icon, then I'd love to know how you launched a shortcut from the task scheduler!
My Computer

8. Oh. I understand where you're coming from now; I've run into the problem you've been trying to explain.

It's a bug... or at least that's what I'm calling it.

So, if a user attempts to schedule, within Task Scheduler, a Shortcut (.lnk) file (that has a custom icon) that links to a program or script, when the task is due to run, it will run normally but it does not inherit the icon the triggered Shortcut file features. Instead, the program will display the icon it's executable is embedded with.

I am at loss as to why this happens. It shouldn't.

However, I have a potential fix (more of a work-around) that you might like to try, Swiftie. When I tested my "fix", it didn't seem to have an effect on the top left corner icon of the GUI-less program's window (sadly), but it's icon on the taskbar had changed with good success.

Here's what I did: Instead of direcly invoking the (in your case Rexx) script by inputting it's fully qualified path as the program to run, e.g.

You'd invoke the command prompt, with the parameters of "/c" and "C:\<PathToScript>", e.g.

I tested this once on some random executable on my machine. The method above didn't work for me then. It only worked on my Python script. I can't guraentee it'll work for your Rexx script too, but it is worth a shot.

I hope this gets fixed in Windows 10. And I do hope the above satisfies your needs for now, Swiftie.
My Computer

9. Pyprohly said:
Oh. I understand where you're coming from now...
Thank you for that excellent description. I'll try out your suggestion.

I wonder if something like VisualBasic (VBScript) has the ability to interact with desktop objects? If so, perhaps it could do the equivalent of double-clicking a desktop icon.

Unfortunately, I'm a rank beginner at VBS.
My Computer

10. swiftie said:
If so, perhaps [VBScript] could do the equivalent of double-clicking a desktop icon.
Swiftie, you are a genius, I'm jealous I didn't think to use a Windows script as a Shortcut.

Well the VBScript will just invoke the actual Shortcut to the target script file, seeing as .lnks are the only known way of altering a display icon (as far as I'm concerned).

Here's the VBScript "shortcut" script you mention:
Code:
Dim strCommand, objShell
strCommand = "C:\Location\to\script.rex.lnk"
Set objShell = CreateObject("WScript.Shell")
objShell.Run strCommand,1
(Where "script.rex.lnk" would then point to your actual Rexx script file.)

Solution tested and approved; it works perfectly, not only for scripts but any program!
My Computer

Page 1 of 2 12 Last

Related Discussions
Our Sites