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

  • Home
  • SEARCH
  • 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 609903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:37:00+00:00 2026-05-13T17:37:00+00:00

I have a task and no idea how to tackle it! Basically, I want

  • 0

I have a task and no idea how to tackle it!

Basically, I want to disable the CD drive on a PC so our users can’t use them.

That’s how I want to start anyway – ultimately I’d like an icon in the system tray that allows the CD drive(s) to be locked and unlocked providing you know a password.

I need somewhere to start though – does anyone know how to disable the use of a CD drive in VB.net?

Any help would be appreciated.

Andrew

  • 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-13T17:37:00+00:00Added an answer on May 13, 2026 at 5:37 pm

    I found a way to do this.

    Basically I needed to loop through all the items in the device manager like this:

    search = New System.Management.ManagementObjectSearcher("SELECT * From Win32_PnPEntity")
                For Each info In search.Get()
                    ' Go through each device detected.
                Next
    

    I then took the DeviceID and ClassGuid sections.

    If the Guid matched {4D36E965-E325-11CE-BFC1-08002BE10318} which is the GUID for a CD/DVD player, I told it to disable/enable the device dependent on what the user wanted to do.

    To enable or disable them, I found this handy program all ready to go from here .

    I then simply edited Form1.vb this:

    Imports System.Management
    

    Public Class Form1

    Private Sub btnEnable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnable.Click
        getCdDrives("Enable")
    End Sub
    
    Private Sub btnDisable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisable.Click
        getCdDrives("Diable")
    End Sub
    
    Public Function getCdDrives(ByVal EnableOrDisable As String) As Boolean
        If InputBox("password") = "password" Then
            Try
                Dim info As System.Management.ManagementObject
                Dim search As System.Management.ManagementObjectSearcher
                Dim deviceGuid As String
                Dim deviceType As String
                Dim cameraIsSeenByWindows As Boolean = False
                Dim showDebugPrompts As Boolean = False
                Dim actualGuid As Guid
    
                search = New System.Management.ManagementObjectSearcher("SELECT * From Win32_PnPEntity")
                For Each info In search.Get()
                    ' Go through each device detected.
                    deviceType = CType(info("DeviceID"), String)
                    deviceGuid = CType(info("ClassGuid"), String)
                    If deviceGuid = "{4D36E965-E325-11CE-BFC1-08002BE10318}" Then
                        actualGuid = New Guid(deviceGuid)
                        If EnableOrDisable = "Enable" Then
                            DeviceHelper.SetDeviceEnabled(actualGuid, deviceType, True)
                        Else
                            DeviceHelper.SetDeviceEnabled(actualGuid, deviceType, False)
                        End If
                    End If
                Next
                If EnableOrDisable = "Enable" Then
                    btnDisable.Enabled = True
                    btnEnable.Enabled = False
                Else
                    btnDisable.Enabled = False
                    btnEnable.Enabled = True
                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        Else
            MsgBox("Oooh Va Vu!!")
        End If
    End Function
    

    End Class

    That will then loop through the CD/DVD drives in device manager and disable/enable them.

    I have yet to tidy the code up – and I need to run the script as a thread because it hangs at the moment while it’s doing it’s thing.

    I also intend to get the program to work out what state the CD drives are in using a timer event – and then report back accordingly… I then need to get it to run in the system tray with no form and finally get it to run as the LSA with desktop interaction enabled.

    I’ll finish it when I get a moment – but everything you need should be here.

    Hope this helps someone out a bit!

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

Sidebar

Related Questions

I have a task and I want to generate some code using the CodeDom.
I have a Task object that has a collection of Label objects ... in
I have a backroundrb scheduled task that takes quite a long time to run.
I have a Rakefile with a Rake task that I would normally call from
I have task to give in my application possibility to open document that is
Suppose I have a task that is pulling elements from a java.util.concurrent.BlockingQueue and processing
I have a task that launches several child tasks. (e.g., Task A creates B,C,D,E,F).
I have no idea how to do this simple task. LightSwitch's Solution Explorer is
I have a rather (for me) complicated task with jQuery. I want to scan
In IntelliJ IDEA I have this task in my Ant script <target name=emulator-logcat> <exec

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.