By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,367 Members | 1,400 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,367 IT Pros & Developers. It's quick & easy.

Problem with Win32_Product - Upgrade method -1636 error code

P: 53
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........
Mar 21 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.