首页 > 代码库 > 禁止光盘优盘自动播放(Shell Hardware Detection服务)

禁止光盘优盘自动播放(Shell Hardware Detection服务)

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery ("Select * from Win32_Service where Name = ‘ShellHWDetection‘")
For Each objService in colServiceList
If objService.State = "Running" Then
objService.StopService()
Wscript.Sleep 5000
End If
errReturnCode = objService.ChangeStartMode("Disabled")
Next

禁止光盘优盘自动播放(Shell Hardware Detection服务)