In my last project, I face a scenario where we need to uninstall previous version installed on the machine, before installing the new version. Although that requirement was later on pulled back, but since then I came to know how we can uninstall a product from within our code.
UninstallApplication:
UninstallApplication function launches the uninstallation that is specified by szUninstallKey.
Syntax:
UninstallApplication(szUninstallKey,szAdditionalCmdLine,nOptions)
Parameters:
szUninstallKey --
Specifies the name of a subkey under the target registry's [root]\Software\Microsoft\Windows\CurrentVersion\Uninstall key; the function first
checks for the subkey under the root key HKEY_CURRENT_USER, and if it does not
find the subkey there, it checks under HKEY_LOCAL_MACHINE. For setups created
with InstallShield Professional 5.53 or earlier, this is typically the name of the application; for setups created with InstallShield Professional 6.0 or later, this is the application's product GUID including the surrounding braces ({}). Do not enter the product GUID of the current setup.
szAdditionalCmdLine:
Specifies any additional command line arguments that you want to pass to the uninstallation. You do not need to specify command line arguments that are already specified in szUninstallKey's UninstallString value's data.
nOptions:
Specifies additional options. You can specify any option that is supported by LaunchApplication
Example:
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
sExeRegistryPath="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\InstallShield_{D0BAAF19-362E-48C7-8640-43B66DD381E5}";
if (RegDBKeyExist(sExeRegistryPath) = 1) then
szUninstallKey = "";
szUninstallKey = "InstallShield_{D0BAAF19-362E-48C7-8640-43B66DD381E5}";
//Specified for silent uninstallation
szAdditionalCmdLine="/uninst";
UninstallApplication ( szUninstallKey, szAdditionalCmdLine, LAAW_OPTION_WAIT||LAAW_OPTION_MINIMIZED);
abort;
endif;
UninstallApplication:
UninstallApplication function launches the uninstallation that is specified by szUninstallKey.
Syntax:
UninstallApplication(szUninstallKey,szAdditionalCmdLine,nOptions)
Parameters:
szUninstallKey --
Specifies the name of a subkey under the target registry's [root]\Software\Microsoft\Windows\CurrentVersion\Uninstall key; the function first
checks for the subkey under the root key HKEY_CURRENT_USER, and if it does not
find the subkey there, it checks under HKEY_LOCAL_MACHINE. For setups created
with InstallShield Professional 5.53 or earlier, this is typically the name of the application; for setups created with InstallShield Professional 6.0 or later, this is the application's product GUID including the surrounding braces ({}). Do not enter the product GUID of the current setup.
szAdditionalCmdLine:
Specifies any additional command line arguments that you want to pass to the uninstallation. You do not need to specify command line arguments that are already specified in szUninstallKey's UninstallString value's data.
nOptions:
Specifies additional options. You can specify any option that is supported by LaunchApplication
Example:
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
sExeRegistryPath="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\InstallShield_{D0BAAF19-362E-48C7-8640-43B66DD381E5}";
if (RegDBKeyExist(sExeRegistryPath) = 1) then
szUninstallKey = "";
szUninstallKey = "InstallShield_{D0BAAF19-362E-48C7-8640-43B66DD381E5}";
//Specified for silent uninstallation
szAdditionalCmdLine="/uninst";
UninstallApplication ( szUninstallKey, szAdditionalCmdLine, LAAW_OPTION_WAIT||LAAW_OPTION_MINIMIZED);
abort;
endif;
Hi Amit
ReplyDeleteOne question:
My application gets installed on multiple systems. Version 11.0 of my application is installed using a installer built through Deployment project of Visual Studio.
Now I am creating a new installer with Installshield. UninstallApplication function requires a Uninstall key will can be diff on diff machines. How can I get that key on runtime?