Hi all,
I am trying to do Software upgradation using Win32_Product -Upgrade method in C#.Net.
Here is the code.
using System;
using System.Management;
using System.Windows.Forms;
namespace WMISample
{
public class CallWMIMethod
{
public static void Main()
{
try
{
ManagementObject classInstance =
new ManagementObject("root\\CIMV2",
"Win32_Product.IdentifyingNumber='{AC76BA86-7AD7-1033-7B44-A00000000001}',Name='Adobe Reader 6.0.1',Version='006.000.001'",
null);
// Obtain in-parameters for the method
ManagementBaseObject inParams =
classInstance.GetMethodParameters("Upgrade");
// Add the input parameters.
inParams["PackageLocation"] = @"D:\softwares\upgradePatch.msi";
// Execute the method and obtain the return values.
ManagementBaseObject outParams =
classInstance.InvokeMethod("Upgrade", inParams, null);
// List outParams
Console.WriteLine("Out parameters:");
Console.WriteLine("ReturnValue: " + outParams["ReturnValue"]);
}
catch(ManagementException err)
{
MessageBox.Show("An error occurred while trying to execute the WMI method: " + err.Message);
}
}
}
}
When I run this code , I am getting 1636 error code, means the patch file is not correct.
But when I manually do the upgradation by double clicking on that msi file, upgradation is success. Then what is problem in this code. How to do it programatically. any suggessions plz........