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 8210227
In Process

The Archive Base Latest Questions

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

while programming throughout the years I have never posted a question on this website,

  • 0

while programming throughout the years I have never posted a question on this website, but I have encounted numerous of problems that had been addressed here before. Now, however, I encountered a problem that I can’t seem to find an answer to.

I am creating an application in which I need information from the ShadowCopies on the system. I am trying to achieve this by using WMI (in C#). This is however giving me an “Initialization Failure”-exception.
Here’s the code:
ManagementScope scope = new ManagementScope(“\\.\ROOT\cimv2”);

//create object query
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_ShadowCopy");

//create object searcher
ManagementObjectSearcher searcher =
                        new ManagementObjectSearcher(scope, query);

//get collection of WMI objects
ManagementObjectCollection queryCollection = searcher.Get();

//enumerate the collection.
foreach (ManagementObject m in queryCollection) 
{
// access properties of the WMI object
  Console.WriteLine("ClientAccessible : {0}", m["ClientAccessible"]);

}

Whenever the foreach line is reached, a ManagementException is thrown with the message “Initialization Failure”. I have absolutely no clue why this is happening. If I use the exact same code and change the WMI-class (to Win32_Processor/Win32_LogicalDisk/…) I am not getting this exception and the foreach-loop just works. I also noticed that the exception comes forth from the statement “searcher.Get();”.
I have tried this code on a Windows Server 2008-machine as well as on a Windows 7 Enterprise-machine, both generating the same exception.

I have also tried using this class in a vb-script and that worked.
Code of VBS:

Set objWMIService = GetObject("winmgmts:\\" + ComputerName + "\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ShadowCopy")

For Each objItem in colItems
    Wscript.Echo objItem.ClientAccessible
Next

I am really clueless on what is generating this exception, especially since the WMI-class is working when I use a VB-script. Does anybody see what I am doing wrong here? Any help is appreciated and if you need more information to resolve this issue, just let me know!

Greetz,
Simon

//NOTE: I got this code from http://include.wutils.com/wmi/ROOT%5Ccimv2/CIM_ManagedSystemElement/CIM_LogicalElement/Win32_ShadowCopy/cs-samples.html

  • 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:00:24+00:00Added an answer on June 7, 2026 at 10:00 am

    I had the same issue with a script I wrote that performs live WIM backups. Is the system you’re running this on have UAC? If so, try either turning it off or running the app as Administrator – as soon as I did that it sprung to life.

    Hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question occured to me while programming a Android application, but it seems to
Hey, while programming stuff, I have found that it is often very helpful to
I'm programming in PHP (PDO). I have done this in gedit, but now I'm
I'm currently encountering this issue while programming Metro, but I'm sure it applies to
While programming, the longest part is a build on my ASP.NET Website project is
I was just wondering while programming. I have got a rootViewController which creates an
What specific techniques have you found to learn keyboard shortcuts while programming? I don't
Recently, I use Vim as my editor while programming Ruby, but I don't know
While programming under eclipse+PyDev and using Flask framework, I noticed that the auto-organizing imports
Something that happens to me a lot while web programming: I want to run

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.