Calling Win32_CDROMDrive freezes the code if the optical drive is burning a disc

StewartBW 1,360 Reputation points
2025-03-19T01:05:06.53+00:00

Hi

Using MySearcher As New ManagementObjectSearcher(New SelectQuery("Win32_CDROMDrive"))
   For Each MyDisk As ManagementObject In MySearcher.Get()
      ' Just here the code execution hangs if the only optical drive is writing a Blu-ray disc!

The drive is Pioneer BDR-S09XLT original firmware!

Any advise please?

Thanks all :)

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,823 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jiachen Li-MSFT 34,206 Reputation points Microsoft External Staff
    2025-03-19T03:20:04.9666667+00:00

    Hi @StewartBW ,

    The ManagementObjectSearcher.Get() call can hang indefinitely because the WMI query waits for a response from the drive, which might not be able to respond while burning.

    You can run the query in a separate thread and enforce a timeout.

    Best Regards.

    Jiachen Li


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.