Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8211545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:27:41+00:00 2026-06-07T10:27:41+00:00

I am trying to convert the following code to C# using WMI and the

  • 0

I am trying to convert the following code to C# using WMI and the System.Management library. Could anyonepoint me in the right direction or offer some help.

var IMPORT_CHILDREN = 0; // Recursively imports the subkeys of the specified key. 
var IMPORT_INHERITED = 1; // Imports the inherited properties of the keys.  
var IMPORT_NODE_ONLY = 2; // Does not import subkeys from the specified file. 
var IMPORT_MERGE = 4; // Merges the imported keys into the existing configuration instead of completely replacing what is there. 

var strPassword = "ExportingPassw0rd"; 
var strFilePath = "C:\\exported.xml"; 
var strSourceMetabasePath = "/lm/logging/custom logging"; // As represented in the metabase.xml file. 
var strDestinationMetabasePath = "/lm/logging/custom logging"; // Can be different from the source. 
var intFlags = IMPORT_NODE_ONLY | IMPORT_INHERITED; // Import only the node with inherited properties. 

// Make connections to WMI, to the IIS namespace on MyMachine, and to the IIsComputer object. 
var locatorObj = new ActiveXObject("WbemScripting.SWbemLocator"); 
var providerObj = locatorObj.ConnectServer("MyMachine", "root/MicrosoftIISv2"); 
var computerObj = providerObj.get("IIsComputer='LM'"); 

// Call export method from the computer object. 
computerObj.Import(strPassword, strFilePath, strSourceMetabasePath, strDestinationMetabasePath, intFlags); 

// Print results. 
WScript.Echo("Imported the node in " + strFilePath + " to " + strDestinationMetabasePath);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:27:43+00:00Added an answer on June 7, 2026 at 10:27 am

    .net 4.0:

        dynamic locatorObj = Activator.CreateInstance(Type.GetTypeFromProgID(("WbemScripting.SWbemLocator")));
        dynamic providerObj = locatorObj.ConnectServer("MyMachine", "root/MicrosoftIISv2");  
        dynamic computerObj = providerObj.get("IIsComputer='LM'");
    
        computerObj.Import(strPassword, strFilePath, strSourceMetabasePath, strDestinationMetabasePath, intFlags);  
    

    .net 3.5 and below:

        var locatorObj = Activator.CreateInstance(Type.GetTypeFromProgID(("WbemScripting.SWbemLocator")));
        var providerObj = locatorObj._I("ConnectServer", "MyMachine", "root/MicrosoftIISv2");  
        var computerObj = providerObj._I("get", "IIsComputer='LM'");
    
        computerObj._I("Import", strPassword, strFilePath, strSourceMetabasePath, strDestinationMetabasePath, intFlags);  
    
    
    public static class ReflectionHlp
    {
      public static object _I(this object item, string name, params object[] args)
      {
        if (item == null)
          return null;
        return item.GetType().InvokeMember(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, item, args);
      }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just trying to convert a PPT using the following URL http://code.google.com/p/qifei/wiki/PDFConverter python
I am trying to convert string into NSDate using following code. NSString *old =
I'm trying to convert some VC++ 6 code to a console app using only
I'm trying to convert the following bash code into C++ using boost::iostreams: #!/usr/bin/bash (
I'm trying to convert to Java some code that uses SDL. I'm using the
I am trying to convert my date from NSString to NSDate using following code
I am trying to convert the following code from Trefethen's Spectral Methods in MATLAB
I m trying to convert the following code to another AJAX call, in order
I am trying to convert following table data into nested array using PHP. I
I am trying to convert code from J# to C# automaticly using the dotPeek

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.