<p>I'm able to successfully uninstall a third-party application via the command line and via a custom Inno Setup installer. </p>

<p>Command line Execution:</p>

<pre><code>MSIEXEC.exe /x {14D74337-01C2-4F8F-B44B-67FC613E5B1F} /qn
</code></pre>

<p>Inno Setup Command:</p>

<pre><code>[Run]
Filename: msiexec.exe; Flags: runhidden waituntilterminated; 
Parameters: "/x {{14D74337-01C2-4F8F-B44B-67FC613E5B1F} /qn";
StatusMsg: "Uninstalling Service...";
</code></pre>

<p>I am also able to uninstall the application programmatically when executing the following C# code in debug mode.</p>

<p>C# Code:</p>

<pre><code>string fileName = "MSIEXEC.exe";
string arguments = "/x {14D74337-01C2-4F8F-B44B-67FC613E5B1F} /qn";

ProcessStartInfo psi = new ProcessStartInfo(fileName, arguments)
{
    CreateNoWindow = true,
    UseShellExecute = false,
    RedirectStandardOutput = true
};

Process process = Process.Start(psi);
string errorMsg = process.StandardOutput.ReadToEnd();
process.WaitForExit();
</code></pre>

<p>The same C# code, however, produces the following failure output when run as a compiled, deployed Windows Service: </p>

<pre><code>"This action is only valid for products that are currently installed."
</code></pre>

<p>Additional Comments:</p>

<ul>
<li>The Windows Service which is issuing
the uninstall command is running on
the same machine as the code being
tested in Debug Mode. The Windows
Service is running/logged on as the
Local system account.  </li>
<li>I have consulted my application logs
and I have validated that the
executed command arguments are thhe
same in both debug and release mode.</li>
<li>I have consulted the Event Viewer
but it doesn't offer any clues.</li>
</ul>

<p>Thoughts? Any help would be greatly appreciated. Thanks.</p>

[{'answer_id': 55496, 'author': 'Orion Edwards', 'author_id': 234, 'author_profile': 'https://Stackoverflow.com/users/234', 'pm_score': 2, 'selected': False, 'text': '<p><strong>Step 1:</strong> <a href="https://stackoverflow.com/questions/15109/visual-studio-2005-setup-project-install-crashes-over-terminal-server#15286">Check the MSI error log files</a></p>\n\n<p>I\'m suspicious that your problem is due to running as LocalSystem. </p>\n\n<p>The Local System account is not the same as a normal user account which happens to have admin rights. It has no access to the network, and its interaction with the registry and file system is quite different.</p>\n\n<p>From memory any requests to read/write to your \'home directory\' or HKCU under the registry actually go into either the default user profile, or in the case of temp dirs, <code>c:\\windows\\temp</code></p>\n'}, {'answer_id': 55571, 'author': 'saschabeaumont', 'author_id': 592, 'author_profile': 'https://Stackoverflow.com/users/592', 'pm_score': 2, 'selected': False, 'text': '<p>I\'ve come across similar problems in the past with installation, a customer was using the SYSTEM account to install and this was causing all sorts of permission problems for non-administrative users. </p>\n\n<p>MSI log files aren\'t really going to help if the application doesn\'t appear "installed", I\'d suggest starting with capturing the output of <code>MSIINV.EXE</code> under the system account, that will get you an "Inventory" of the currently installed programs (or what that user sees installed) <a href="http://blogs.msdn.com/brada/archive/2005/06/24/432209.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/brada/archive/2005/06/24/432209.aspx</a></p>\n\n<p>I think you probably need to go back to the drawing board and see if you really need the windows  service to do the uninstall. You\'ll probably come across all sorts of Vista UAC issues if you haven\'t already...</p>\n'}, {'answer_id': 57801, 'author': 'Ben Griswold', 'author_id': 4115, 'author_profile': 'https://Stackoverflow.com/users/4115', 'pm_score': 2, 'selected': True, 'text': '<p>Thanks to those offering help. This appears to be a permissions issue. I have updated my service to run under an Administrator account and it was able to successfully uninstall the third-party application. To Orion\'s point, though the Local System account is a powerful account that has full access to the system -- <a href="http://technet.microsoft.com/en-us/library/cc782435.aspx" rel="nofollow noreferrer">http://technet.microsoft.com/en-us/library/cc782435.aspx</a> -- it doesn\'t seem to have the necessary rights to perform the uninstall.</p>\n\n<p>[See additional comments for full story regarding the LocalSystem being able to uninstall application for which it installed.]</p>\n'}, {'answer_id': 58197, 'author': 'Paul Lalonde', 'author_id': 5782, 'author_profile': 'https://Stackoverflow.com/users/5782', 'pm_score': 0, 'selected': False, 'text': "<p>This is bizarre. LocalSystem definitely has the privileges to install applications (that's how Windows Update and software deployment in Active Directory work), so it should be able to uninstall as well.</p>\n\n<p>Perhaps the application is initially installed per-user instead of per-machine?</p>\n"}, {'answer_id': 60079, 'author': 'Ben Griswold', 'author_id': 4115, 'author_profile': 'https://Stackoverflow.com/users/4115', 'pm_score': 0, 'selected': False, 'text': "<p>@Paul Lalonde</p>\n\n<p>The app's installer is wrapped within a custom InnoSetup Installer. The InnoSetup installer, in turn, is manually executed by the logged in user. That said, the uninstall is trigged by a service running under the Local System account. </p>\n\n<p>Apparently, you were on to something.  I put together a quick test which had the service running under the LocalSystem account install as well as uninstall the application and everything worked flawlessly.  You were correct.  The LocalSystem account has required uninstall permissions for applications in which it installs.  You saved the day.  Thanks for the feedback! </p>\n"}]
['https://Stackoverflow.com/questions/55482', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4115/']