操作注册表、个给你个功能类似的
[url]http://zhidao.baidu.com/question/389504172.html?an=0&si=1[/url]
Opt("MustDeclareVars", 1)
If Not FileExists(@ScriptDir & "\声卡硬件id.ini") Then
MsgBox(16, "配置文件不存在", "请检查配置文件:" & @CRLF & @ScriptDir & "\声卡硬件id.ini")
Exit
EndIf
If Not FileExists(@ScriptDir & "\devcon.exe") Then
MsgBox(16, "devcon.exe文件不存在", "请检查:" & @CRLF & @ScriptDir & "\devcon.exe")
Exit
EndIf
Local $key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
Local $reg = RegRead($key, "jiankong")
If @error Then
RegWrite($key, "jiankong", "REG_SZ", @ScriptDir & "\启用禁用声卡.exe")
MsgBox(0, "启动键值写入注册表", "下次开机将自启动本程序,请按[确定]退出")
Exit
EndIf
Local $hardid = IniRead (@ScriptDir & "\声卡硬件id.ini", "参数", "id", "")
Local $exefile = IniRead (@ScriptDir & "\声卡硬件id.ini", "参数", "exe", "")
Local $delay = IniRead (@ScriptDir & "\声卡硬件id.ini", "参数", "sec", "8")
If $hardid = "" Or $exefile = "" Then
MsgBox(16, "配置文件出错", "请检查配置文件:" & @CRLF & @ScriptDir & "\声卡硬件id.ini")
Exit
EndIf
Local $command_dis = @ScriptDir & "\devcon.exe disable " & '"' & $hardid & '"'
Local $command_en = @ScriptDir & "\devcon.exe enable " & '"' & $hardid & '"'
RunWait(@ComSpec & " /c " & $command_dis, "", @SW_HIDE)
Sleep(1000*Number($delay))
Run($exefile)
Sleep(1000*Number($delay));;;;这行缺了个 ) 导致bug
RunWait(@ComSpec & " /c " & $command_en, "", @SW_HIDE)
ToolTip("完成!" & @CRLF & "谢谢使用!", @DesktopWidth/2, @DesktopHeight/2)
Sleep(3000)
|