'wshshell.shell是一个注册表修改对象,有三个方法regwrite,regread,regdelete
'Set WshShell = CreateObject("WScript.Shell")
'WshShell.RegWrite "HKEY_CURRENT_USER\Software\zxlxxl\aa", "某些字符串值"
'WshShell.RegWrite "HKEY_CURRENT_USER\Software\zxlxxl\a1", 1, "REG_DWORD"
'wshshell.regdelete "HKEY_CURRENT_USER\Software\zxlxxl\"
Private Sub conCdRom(b As Boolean)
Set WshShell = CreateObject("WScript.Shell")
If b Then
'启用光bai驱
WshShell.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Cdrom\Start", 1, "REG_DWORD"
Else
'禁用光驱
WshShell.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Cdrom\Start", 4, "REG_DWORD"
End If
msgbxo "本次操作重启生效"
End Sub
Private Sub conUSB(b As Boolean)
Set WshShell = CreateObject("WScript.Shell")
If b Then
'启用USB
WshShell.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR\Start", 3, "REG_DWORD"
Else
'禁用USB
WshShell.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR\Start", 4, "REG_DWORD"
End If
MsgBox "本次操作重启生效"
End Sub
Private Sub Command1_Click()
conCdRom True
End Sub
Private Sub Command2_Click()
conCdRom False
End Sub
Private Sub Command3_Click()
conUSB True
End Sub
Private Sub Command4_Click()
conUSB False
End Sub
Private Sub Form_Load()
Command1.Caption = "启用光驱"
Command2.Caption = "禁用光驱"
Command3.Caption = "启用USB"
Command4.Caption = "启用USB"
End Sub