I\'m trying to set the icon in Add or Remove Programs to the same as my a
You can manually change these details under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
Some of the valid accepted key values:
If both NoModify and NoRepair are set to 1, the button displays "Remove" instead of "Modify/Remove".
For example:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinRAR archiver]
"DisplayName"="WinRAR 4.20 (64-bit)"
"DisplayVersion"="4.20.0"
"VersionMajor"=dword:00000004
"VersionMinor"=dword:00000014
"UninstallString"="C:\\Program Files\\WinRAR\\uninstall.exe"
"DisplayIcon"="C:\\Program Files\\WinRAR\\WinRAR.exe"
"InstallLocation"="C:\\Program Files\\WinRAR\\"
"NoModify"=dword:00000001
"NoRepair"=dword:00000001
"Language"=dword:00000000
"Publisher"="win.rar GmbH"
You can change (or create it if it does not exist) the value of the DisplayIcon
key. This will change the uninstaller icon in Add or Remove Programs in the control panel.
Windows installer supports property by which you can add Icon ARPPRODUCTICON
. To Set this property we need to add icon in your installer using Icon
element.
<Icon Id="icon.ico" SourceFile="MySourceFiles\icon.ico"/>
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
This will add icon in Control Panel.
I found an extremely simple solution. Under your deployment project's properties, click the "AddRemoveProgram" and browse for your file. I recommend dropping your application's icon in your Application folder.
Yes, you can do it by this code:
string Install_Reg_Loc = @"Software\Microsoft\Windows\CurrentVersion\Uninstall";
string displayIcon = @"C:\MorganTech\setup-icon.ico";
RegistryKey hKey = (Registry.LocalMachine).OpenSubKey(Install_Reg_Loc, true);
RegistryKey appKey = hKey.OpenSubKey(productName);
appKey.SetValue("DisplayIcon", (object)displayicon, RegistryValueKind.String)
The easy way- on first start up run this code (vb .net):
Dim myUninstallKey As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Uninstall")
dim iconSourcePath As String = "c:\myprogram\myprogram.exe,0"
Dim mySubKeyNames As String() = myUninstallKey.GetSubKeyNames()
For i As Integer = 0 To mySubKeyNames.Length - 1
Dim myKey As RegistryKey = myUninstallKey.OpenSubKey(mySubKeyNames(i), True)
Dim myValue As Object = myKey.GetValue("DisplayName")
If myValue IsNot Nothing AndAlso myValue.ToString() = "YourProgaram" Then
myKey.SetValue("DisplayIcon", iconSourcePath)
Exit For
End If
Next
or c#
RegistryKey myUninstallKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Uninstall");
string iconSourcePath = "c:\myprogram\myprogram.exe,0";
string[] mySubKeyNames = myUninstallKey.GetSubKeyNames();
for (int i = 0; i <= mySubKeyNames.Length - 1; i++) {
RegistryKey myKey = myUninstallKey.OpenSubKey(mySubKeyNames(i), true);
object myValue = myKey.GetValue("DisplayName");
if (myValue != null && myValue.ToString() == "YourProgaram") {
myKey.SetValue("DisplayIcon", iconSourcePath);
break; // TODO: might not be correct. Was : Exit For
}
}
In Visual Studio 2017 Community edition:
Select the installer project and press F4 (mouse clicking is not helpful this time, but I swear I got it through another way before.)