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.Manageme nt;
using System.Windows. Forms;
namespace WMISample
{
public class CallWMIMethod
{
public static void Main()
{
try
{
ManagementObjec t classInstance =
new ManagementObjec t("root\\CIMV2" ,
"Win32_Product. IdentifyingNumb er='{AC76BA86-7AD7-1033-7B44-A00000000001}', Name='Adobe Reader 6.0.1',Version= '006.000.001'",
null);
// Obtain in-parameters for the method
ManagementBaseO bject inParams =
classInstance.G etMethodParamet ers("Upgrade");
// Add the input parameters.
inParams["PackageLocatio n"] = @"D:\softwares\ upgradePatch.ms i";
// Execute the method and obtain the return values.
ManagementBaseO bject outParams =
classInstance.I nvokeMethod("Up grade", inParams, null);
// List outParams
Console.WriteLi ne("Out parameters:");
Console.WriteLi ne("ReturnValue : " + outParams["ReturnValu e"]);
}
catch(Managemen tException 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........
I am trying to do Software upgradation using Win32_Product -Upgrade method in C#.Net.
Here is the code.
using System;
using System.Manageme nt;
using System.Windows. Forms;
namespace WMISample
{
public class CallWMIMethod
{
public static void Main()
{
try
{
ManagementObjec t classInstance =
new ManagementObjec t("root\\CIMV2" ,
"Win32_Product. IdentifyingNumb er='{AC76BA86-7AD7-1033-7B44-A00000000001}', Name='Adobe Reader 6.0.1',Version= '006.000.001'",
null);
// Obtain in-parameters for the method
ManagementBaseO bject inParams =
classInstance.G etMethodParamet ers("Upgrade");
// Add the input parameters.
inParams["PackageLocatio n"] = @"D:\softwares\ upgradePatch.ms i";
// Execute the method and obtain the return values.
ManagementBaseO bject outParams =
classInstance.I nvokeMethod("Up grade", inParams, null);
// List outParams
Console.WriteLi ne("Out parameters:");
Console.WriteLi ne("ReturnValue : " + outParams["ReturnValu e"]);
}
catch(Managemen tException 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........