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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:37:48+00:00 2026-05-27T03:37:48+00:00

How to detect network drive mount event using wmi ? I’m mainly interested i

  • 0

How to detect network drive mount event using wmi ? I’m mainly interested i something like Win32_VolumeChangeEvent just for network drives.

 _eventWatcher = new ManagementEventWatcher("SELECT * FROM Win32_VolumeChangeEvent");

 _eventWatcher.EventArrived += (o, args) => 
     {switch(args.NewEvent["EventType"].ToString()[0])
         {
             case '2':
                 //mount
                 Debug.WriteLine(args.NewEvent["DriveName"]);
                 break;
             case '3':
                 //unmount
                 break;
         }
     };

 _eventWatcher.Start();

Thanks in advance.

  • 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-05-27T03:37:48+00:00Added an answer on May 27, 2026 at 3:37 am

    You can use this query (I use Powershell for rapid test but you can easily transform to C#)

    $query = "SELECT * FROM __instanceCreationEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_LogicalDisk' AND TargetInstance.DriveType=4"
    
    Register-WMIEvent -Query $query -Action {$global:a=$Args[0];$global:b=$Args[1];write-host "done" }
    
    Id              Name            State      HasMoreData     Location  Command
    --              ----            -----      -----------     --------  -------
    14              f2c5223d-3ae... NotStarted False                     $global:a=$Args[0];$gl...
    
    
    PS C:\> net use
    Les nouvelles connexions seront mémorisées.
    
    La liste est vide.
    
    PS C:\> net use o: \\jpbhpp2\c$
    La commande s'est terminée correctement.
    
    PS C:\> done
    
    
    PS C:\> $a
    
    
    Scope     : System.Management.ManagementScope
    Query     : System.Management.EventQuery
    Options   : System.Management.EventWatcherOptions
    Site      :
    Container :
    
    
    
    PS C:\> $b
    
    NewEvent                                                    Context
    --------                                                    -------
    System.Management.ManagementBaseObject                      {}
    
    
    PS C:\> $b.NewEvent
    
    
    __GENUS             : 2
    __CLASS             : __InstanceCreationEvent
    __SUPERCLASS        : __InstanceOperationEvent
    __DYNASTY           : __SystemClass
    __RELPATH           :
    __PROPERTY_COUNT    : 3
    __DERIVATION        : {__InstanceOperationEvent, __Event, __IndicationRelated, __SystemClass}
    __SERVER            : WM2008R2ENT
    __NAMESPACE         : //./root/CIMV2
    __PATH              :
    SECURITY_DESCRIPTOR :
    TargetInstance      : System.Management.ManagementBaseObject
    TIME_CREATED        : 129670237461553750
    
    
    
    PS C:\> $b.NewEvent.TargetInstance
    
    
    __GENUS                      : 2
    __CLASS                      : Win32_LogicalDisk
    __SUPERCLASS                 : CIM_LogicalDisk
    __DYNASTY                    : CIM_ManagedSystemElement
    __RELPATH                    : Win32_LogicalDisk.DeviceID="O:"
    __PROPERTY_COUNT             : 40
    __DERIVATION                 : {CIM_LogicalDisk, CIM_StorageExtent, CIM_LogicalDevice, CIM_LogicalElement...}
    __SERVER                     : WM2008R2ENT
    __NAMESPACE                  : root\CIMV2
    __PATH                       : \\WM2008R2ENT\root\CIMV2:Win32_LogicalDisk.DeviceID="O:"
    Access                       : 0
    Availability                 :
    BlockSize                    :
    Caption                      : O:
    Compressed                   : False
    ConfigManagerErrorCode       :
    ConfigManagerUserConfig      :
    CreationClassName            : Win32_LogicalDisk
    Description                  : Connexion réseau
    DeviceID                     : O:
    DriveType                    : 4
    ErrorCleared                 :
    ErrorDescription             :
    ErrorMethodology             :
    FileSystem                   : NTFS
    FreeSpace                    : 36223737856
    InstallDate                  :
    LastErrorCode                :
    MaximumComponentLength       : 255
    MediaType                    : 0
    Name                         : O:
    NumberOfBlocks               :
    PNPDeviceID                  :
    PowerManagementCapabilities  :
    PowerManagementSupported     :
    ProviderName                 : \\jpbhpp2\c$
    Purpose                      :
    QuotasDisabled               : True
    QuotasIncomplete             : False
    QuotasRebuilding             : False
    Size                         : 500000878592
    Status                       :
    StatusInfo                   :
    SupportsDiskQuotas           : True
    SupportsFileBasedCompression : True
    SystemCreationClassName      : Win32_ComputerSystem
    SystemName                   : WM2008R2ENT
    VolumeDirty                  :
    VolumeName                   :
    VolumeSerialNumber           : 96B00597
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using WMI to detect a number of items about a network adapter's
Is it possible to detect that a phone has network connectivity and/or wifi using
What is the best way to detect if a computer on a network is
I want to be able to detect when a computer connects to a network.
How can I detect all WiFi networks availables using Delphi? (source: filebuzz.com )
How do people usually detect the MIME type of an uploaded file using ASP.NET?
Here's what I'm trying to do: using cmd.exe, go to a mounted windows network
I'm writing a port scanner to detect web services running on the local network.
I am learning network programming using twisted 10 in python. In below code is
Now my team working in a network project using windows application c# . I

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.