managementscope.connect time out issue

Posted on 2010-01-06
Last Modified: 2013-11-08
i am having an issue with not being able to get the timeout option to work.
I want to set the time out for 1 min or so but to no avail to get it to work .
i have tried time span also (timespan(0,1,0)

Dim options As New ConnectionOptions
Dim query As ObjectQuery
Dim searcher As ManagementObjectSearcher
Dim queryCollection As ManagementObjectCollection
Dim m As ManagementObject
Dim scope As New ManagementScope("\\" & oName & "\root\cimv2", options)
scope.Options.Timeout = New TimeSpan(20000000)
Catch ex As System.UnauthorizedAccessException
oMsg &= "Connect UnauthorizedAccessException: " & ex.Message
Exit Sub
Catch ex As System.Runtime.InteropServices.COMException
oMsg &= "Connect COMException: " & ex.Message
Exit Sub
End Try

Question by:LeeHopkins
    LVL 13

    Expert Comment


    Timeout Gets or sets the time-out to apply to the operation. Note that for operations that return collections, this time-out applies to the enumeration through the resulting collection, not the operation itself (the ReturnImmediately property is used for the latter). This property is used to indicate that the operation should be performed semisynchronously. (Inherited from ManagementOptions.)


    Author Comment

    so is there a way to limit the scope.Connect() time so my app does not just hang for what ever time?
    LVL 13

    Accepted Solution

    What I would suggest doing is before calling connect chech for a ping reply

    Author Comment

    ?hmm did not know i could do that, How do i do check for a ping reply

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Suggested Solutions

    Normally a window is moved by clicking on the caption bar and dragging. You may want your user to be able to move borderless forms or move a form by clicking anywhere in the form without the limitation to the caption bar. There are many ways to do i…
    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now