吧务
level 14
看看能否去掉cmd.exe /c ,如果还是不能用,尝试ShellExecute这个API
2019年12月04日 17点12分
3
level 14
taskkill 和 explorer 本身就是exe,直接shell它们自身就行了,没有必须走cmd。
2019年12月04日 17点12分
4
level 7
很早之前写过这个原理的 翻出来了 发给你。
Option Explicit
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Const SW_HIDE = 0
Private Const SW_SHOW = 5
Private Sub Command1_Click()
Dim w As String
Dim p As String
Dim c As Object
If Text1.Text <> Text2.Text Then
p = MsgBox("由于解锁密码不正确所以无权运行任何程序", 16, "错误提示")
Else
If Command1.Caption = "解锁" Then
Label2.ForeColor = &HC00000
Label2.Caption = "屏幕正常无锁定状态"
Set c = CreateObject("wscript.shell")
c.regwrite "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\" & "DisableTaskMgr", 0, "REG_DWORD"
Shell "explorer "
Command1.Caption = "锁定"
Close #1
Command2.Visible = True
Else
Label2.Caption = "屏 幕 锁 定 状 态"
Label2.ForeColor = &HFF&
Set c = CreateObject("wscript.shell")
c.regwrite "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\" & "DisableTaskMgr", 1, "REG_DWORD"
Shell "TASKKILL /IM explorer.EXE /F"
Command1.Caption = "解锁"
Open Environ$("WinDir") & "\system32\taskmgr.exe" For Binary As #1
Text1.Text = ""
Command2.Visible = False
End If
End If
End Sub
Private Sub Command2_Click()
Form2.Show
End Sub
Private Sub Form_Load()
On Error GoTo err
Dim p As String
Dim w As Object
Dim c As Object
Set w = CreateObject("wscript.shell")
Text2.Text = w.regread("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Demon\id")
Label2.Caption = "屏 幕 锁 定 状 态"
Label2.ForeColor = &HFF&
Set c = CreateObject("wscript.shell")
c.regwrite "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\" & "DisableTaskMgr", 1, "REG_DWORD"
Shell "TASKKILL /IM explorer.EXE /F"
Command1.Caption = "解锁"
Open Environ$("WinDir") & "\system32\taskmgr.exe" For Binary As #1
Command2.Visible = False
Text1.Text = ""
Exit Sub
err:
p = MsgBox("您好现在没有设置密码请立即设置密码", 16, "错误提示 ")
Form2.Show
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Command1.Caption = "解锁" Then
Close #1
Cancel = True
Else
End If
End Sub
2019年12月05日 02点12分
5
level 7
第二窗体 设置新密码的
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Or Text1.Text <> Text2.Text Or Text1.Text = "'" Or Text2.Text = "'" Then
p = MsgBox("请填写完成信息或密码不一致", 16, "错误提示")
Else
Set w = CreateObject("wscript.shell")
w.regwrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Demon\" & "id", Text1.Text, "REG_SZ"
p = MsgBox("密码设置完成", 64, "信息提示")
Unload Me
Unload Form1
Form1.Show
Form1.Text1.Text = ""
End If
End Sub
Private Sub Form_Load()
End Sub
2019年12月05日 02点12分
6