I am using wix to create the setup file. After installation I want to create an uninstall file so that the user can delete the program. I followed the steps in this link but without success. I am implementing as below. The Setup project compiles and installs without any problems. But I can't see the delete shortcut it created in the application folder. What is the point I missed?
Please let me know if you need more details.
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Application Name">
<Directory Id="en" Name="en" />
<Directory Id="tr" Name="tr" />
<Directory Id="ar_DZ" Name="ar-DZ" />
<Directory Id="cs" Name="cs" />
<Directory Id="cs_CZ" Name="cs-CZ" />
<Directory Id="de" Name="de" />
<Directory Id="fr" Name="fr" />
<Directory Id="fr_FR" Name="fr-FR" />
<Directory Id="pt" Name="pt" />
<Directory Id="pt_BR" Name="pt-BR" />
<Directory Id="Ru" Name="Ru" />
<Directory Id="ru_ru" Name="ru-ru" />
<Directory Id="uz_Latn_UZ" Name="uz-Latn-UZ" />
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="Application Name"/>
</Directory>
</Directory>
</Fragment>
<Fragment>
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcut" Guid="*">
<Shortcut Id="UninstallProduct"
Name="Uninstall Application Name"
Description="Uninstalls Application Name"
Target="[System64Folder]msiexec.exe"/>
<RemoveFolder Id="WindowsFolder" On="uninstall"/>
</Component>
</DirectoryRef>
</Fragment>
CodePudding user response:
You need to send your product code to the msiexec.exe as an argument:
<Shortcut Id=”UninstallShortcut”
Name=”Uninstall my software”
Description=”Uninstalls my software and all its components”
Target=”[System64Folder]msiexec.exe”
Arguments=”/x [ProductCode]” />
CodePudding user response:
I understood the root cause of the problem and wanted to provide an answer in case others have similar problems in the future.
First of all in my code the file would never be created. A shortcut to a non-existent file was not created. This was mainly because the ApplicationShortcut
ID was never defined in the ProductFeature
field. The Component
was referencing the ApplicationShortcut
ID to create the file. A definition like the one below was needed.
<Feature Id="ProductFeature" Title="Application Name" Level="1">
<ComponentRef Id="ApplicationShortcut" />
</Feature>
The first time after noticing this issue, the file would be created in C:\ProgramData\Microsoft\Windows\Start Menu\Programs
. If you want the file to be created where you installed it, you will have to follow the path below.
If you want to create the file in a folder named uninstall within the file path, you must create the target path as follows.
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Application Name">
<Directory Id="uninstall" Name="uninstall" />
</Directory>
</Directory>
</Directory>
</Fragment>
Then you can create your shortcut as follows.
<Fragment>
<DirectoryRef Id="uninstall">
<Component Id="ApplicationShortcut" Guid="GUID-NUMBER">
<Shortcut Id="UninstallProduct"
Name="Uninstall Application Name"
Description="Uninstalls Application Name"
Target="[System64Folder]msiexec.exe"
Arguments="/x [ProductCode]"/>
</Component>
</DirectoryRef>
</Fragment>
If ProductCode is not given in the Arguments field, a shortcut is created, but it shows the error that ProductCode is required during execution.
The Name
field represents the name of the file you will create.
Description
field is the description written in Right Click-> Properties -> Description field.
Note : If you want your file to be created directly in the installation area of the file, not in a folder. You do not need to create the uninstall file. You can delete the field below.
<Directory Id="uninstall" Name="uninstall" />
You can give the installation point as the folder reference as follows.
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
....
</DirectoryRef>
</Fragment>
Note 2: To avoid confusion, the creation of language folders in the code I gave in the question was deleted.