Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Setting the window icon for a command prompt window

27 Jan 2015   #1
swiftie

Windows 7 Ultimate x64
 
 
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 System SpecsSystem Spec
.
27 Jan 2015   #2
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Quote   Quote: Originally Posted by swiftie View Post
[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 System SpecsSystem Spec
27 Jan 2015   #3
swiftie

Windows 7 Ultimate x64
 
 

Quote   Quote: Originally Posted by Pyprohly View Post
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 System SpecsSystem Spec
.

27 Jan 2015   #4
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

We're talking about these, yes?

Setting the window icon for a command prompt window-th-359527.png

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 System SpecsSystem Spec
28 Jan 2015   #5
swiftie

Windows 7 Ultimate x64
 
 

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 System SpecsSystem Spec
28 Jan 2015   #6
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

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 System SpecsSystem Spec
28 Jan 2015   #7
swiftie

Windows 7 Ultimate x64
 
 

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 System SpecsSystem Spec
29 Jan 2015   #8
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

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.

Setting the window icon for a command prompt window-untitled1.png

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

Setting the window icon for a command prompt window-untitled3.png
Setting the window icon for a command prompt window-untitled2.png


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 System SpecsSystem Spec
29 Jan 2015   #9
swiftie

Windows 7 Ultimate x64
 
 

Quote   Quote: Originally Posted by Pyprohly View Post
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 System SpecsSystem Spec
29 Jan 2015   #10
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Quote   Quote: Originally Posted by swiftie View Post
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 System SpecsSystem Spec
Reply

 Setting the window icon for a command prompt window




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Installation stuck with a command prompt window
Hi, I'm having an installation problem. I've previously done an installation of windows7 on my PC with no problems. However, I decided to reinstall windows when my PC was having some issues. I've chosen the 'upgrade' option when reinstalling windows. The problem came when I got a BSOD midway...
Installation & Setup
setting an environmental variable from command prompt
I live in the Linux world, so this might be a stupid question to Windows users. I need to set an environmental variable. I know I can do this through the control panel, but what a pain in the ass. If I open a command prompt and use the "set" command, the variable seems to last only as long as...
General Discussion
taskeng.exe opening in a Command Prompt window
Just now, I was reading posts here when a Command Prompt (black) windows opened, titled taskeng.exe. This is the Task Scheduler, right? Why is it opening a Command Prompt window, never did this before. I noticed The Windows update icon is now in the System area of the TaskBar, so I suspect it...
Windows Updates & Activation
Annoying prompt window
Hello. When I try to open up programs like Defraggler, Malwarebytes, Spybot or Revo Uninstaller that prompt on the pic bugs me. Even after I give all permissions from security tab it still comes. Is there a way to disable it except turning off user account control completely?
General Discussion
Window and Text size in Command Prompt, Windows XP Mode
Anybody know how to change the text size in Windows XP Mode at the command prompt? I've tried right clicking on the DOS shortcut that I set up and changing it there, but it doesn't do anything. Also, I've set it to Full Screen, but everytime I execute a program, it shrinks to a smaller window....
Virtualization
Command Prompt From Explorer Window
How do I open a command prompt from an Explorer Window? Of course it must open at the same path without having to type in navigation commands (that's the whole point). Thanks, Jon
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 01:10.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App