Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have a c# exe that is supposed to unistall another app. the code is as follows:
C#
private void removeApp()
{
    ustAssembly = @"c:\path\tosome\file.exe"
    Assembly ustAsm = Assembly.LoadFrom(ustAssembly);
    string appGUID = "{" + ustAsm.GetType().GUID.ToString() + "}";
    string args = @"/x " + appGUID;
    Process p = new Process();
    p.StartInfo.FileName = "msiexec.exe";
    p.StartInfo.Arguments = args;
    p.StartInfo.UseShellExecute = true;
    p.Start();
    p.WaitForExit();
}

When i run this exe, i get the following message:
"This action is only valid for products that are currently installed"

Just to note: I could have sworn it worked previously but, at my job they removed admin rights to all client machines and incorporated viewfinity to control what users/apps can do on a computer.

I went through a long exercise with a member of our viewfinity team to create policies for this app to work and he even went as far as granting me admin rights to the test machine but, its still not working.

I know this target app that i want to uninstall is in fact already installed on the test computer.
Any clue as to why i'm getting this message? Could it still be a rights issue?
Any help would be appreciated.
Posted
Updated 12-Apr-12 6:15am
v4
Comments
[no name] 12-Apr-12 12:20pm    
Could be a rights issue if the process cannot read the registry to get the GUID.
Member 8045950 12-Apr-12 12:42pm    
I used a message box to see the value of the GUID and it appears to be returning the correct GUID for the app.
[no name] 12-Apr-12 14:14pm    
Does it work from a command line if you type it in outside of the program?

This
C#
ustAssembly = "c:\path\tosome\file.exe"


should either be
C#
ustAssembly = @"c:\path\tosome\file.exe"

or
C#
ustAssembly = "c:\\path\\tosome\\file.exe"
 
Share this answer
 
Comments
Member 8045950 12-Apr-12 12:14pm    
Thanks for the reply. I actually have the path as: @"c:\path\tosome\file.exe". i'll update my question to reflect that.
It turns out that it was actually a rights issue. I was added to the admin group and then somehow, I was dropped from the group. Thanks for your replies.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900