Reputation: 106904
I've got an app that downloads an .exe to a temporary folder and runs it with the System.Diagnostics.Process
class. So far I've run two different apps with it. One is a console app, the other is a full windows app. The windows app has its icon in the taskbar/titlebar, but the console app only has a generic application icon. If I navigate to the temp folder the console app does have its icon; and running it "by hand" (double-clicking in explorer) also gives it the correct icon.
What could be the cause of this?
Additional info: The ProcessStartInfo
class does not offer any flags concerning the icon. I'm running the process with UseShellExecute=true
and ErrorDialog=true
. Also, the windows app is started maximized but the console app is minimized (as specified by the WindowStyle
member of ProcessStartInfo
). Finally, the icon for the console app only includes a 32x32x4bpp icon, while the windows app has a large selection of different formats.
Added: I gave the downloaded app a proper icon. Still no go. :(
Added 2: Oh, right, Windows 7 x64.
Update: Just tried some more experiments. I created a new C++ (unmanaged, not .NET) application with just "press any key to continue" in it and gave it an icon. The icon shows up normally in explorer, and when I run it from explorer, the icon is in the window title bar.
However, when I start the application from Visual studio (via F5 or Ctrl-F5); or when I run the application via another .NET application and Process.Start()
- the icon doesn't appear. Why?
Upvotes: 6
Views: 1954
Reputation: 399
I'm not sure why this happens, but a work-around is to set the WorkingDirectory in the ProcessStartInfo structure to the directory of the EXE.
This works whether UseShellExecute is true or not.
Upvotes: 3
Reputation: 2132
This code shows console application with user defined icon normally:
Process p = new Process();
p.StartInfo = new ProcessStartInfo("ConsoleApplication1.exe")
{
UseShellExecute = true,
ErrorDialog = true,
WindowStyle = ProcessWindowStyle.Minimized
};
p.Start();
Icon file used in my ConsoleApplication1.exe includes all resolutions.
Therefore I think problem source may be in:
Upvotes: 0
Reputation: 6347
I suppose that downloadable app previously didnt have an icon. But now is has, so may be the windows has buffered icon and you just need to reboot. Im not sure. I just tryed to run one console app from another and icons has displayed. But when I changed icon and recompile applications I saw old icon until I have reboot. So its obviously windows problem
Upvotes: 0