Is it possible to define an icon for a process? For example Like:
startInfo.Icon = 'C:\somepath\icon.ico';
The icon should be shown in the taskbar. The only possible way (as far as I know) to achieve this is a link, but I would like to have an other option than creating a link dynamically and start it.
The icon is associated with the executable file of that process so you can't change it. As the only workaround you may create a shortcut to the executable and set a custom icon for the shortcut. Then you can pass the path to the shortcut file into Process.Start
(you need to add a COM reference to Windows Script Host Object Model via Project > Add Reference > COM > Windows Script Host Object Model for this to work):
using System;
using System.Diagnostics;
using IWshRuntimeLibrary;
class Program
{
private static void Main(string[] args)
{
string shortcutAddress = Environment.GetFolderPath(
Environment.SpecialFolder.Desktop) + @"\MyProcess.lnk";
var shell = new WshShell();
var shortcut = (IWshShortcut)shell.CreateShortcut(shortcutAddress);
shortcut.Description = "New shortcut for a Notepad";
shortcut.Hotkey = "Ctrl+Shift+N";
shortcut.TargetPath = Environment.GetFolderPath(
Environment.SpecialFolder.System) + @"\notepad.exe";
shortcut.IconLocation = Environment.GetFolderPath(
Environment.SpecialFolder.System) + @"\calc.exe";
shortcut.Save();
Process.Start(shortcutAddress);
}
}