方法一:
Set WMI=GetObject("winmgmts:\\.\root\cimv2")
Set ProgList=WMI.ExecQuery("Select * From Win32_Process")
For Each Prog In ProgList
If LCase(Prog.Name)="cmd.exe" Then
Prog.Terminate
Exit For
End If
Next
方法二:
Set WshShell=CreateObject("Wscript.Shell")
Set WMI=GetObject("winmgmts:\\.\root\cimv2")
Set ProgList=WMI.ExecQuery("Select * From Win32_Process")
For Each Prog In ProgList
If LCase(Prog.Name)="cmd.exe" Then
wshshell.Run "cmd /c ntsd -c q -p "+Prog.ProcessID,0
Exit For
End If
Next
WshShell.run("%comspec% /k copy c:\123\123.txt c:\234"),1,true
/k参数表示执行指定的命令后保留命令提示窗口
/c参数表示执行指定的命令后关闭命令提示窗口
所以,改为:
WshShell.run("%comspec% /c copy c:\123\123.txt c:\234"),1,true
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.run("%comspec% /c copy c:\123\123.txt c:\234"),1,true
使用动态链接库中的勾子,查找窗口功能!看看行不行