vbs工作时关闭所有文件
可以自己添加想要杀死的进程,在函数ssjc中添加即可如果不知道你打开的软件进程名称,可以打开任务管理器,选中你打开的文件,右击 --选中转到进程即可看到进程名称,添加到里面即可
保存为vbs
执行程序
call ssjc()
sub ssjc()
dim sj(15)
sj(0)="cmd.exe"
sj(1)="SecureCRT.exe"
sj(2)="360chrome.exe"
sj(3)="360MobileMgr.exe"
sj(4)="chrome.exe"
sj(5)="notepad++.exe"
sj(6)="notepad.exe"
sj(7)="Foxmail.exe"
sj(8)="java.exe"
sj(9)="dllhost.exe"
sj(10)="Fiddler.exe"
for i=0 to ubound(sj)
sjj=sj(i)
if sjj<>"" then
'KillProc(sjj)
killpdsfhy(sjj)
end if
next
end sub
'判断是否含有进程
function killpdsfhy(killhy)
On Error Resume Next
Dim WMI,objs,pdzj
Set WMI = GetObject("WinMgmts:")
Set objs = WMI.InstancesOf("Win32_Process")
For Each obj In objs
if obj.Description = killhy then
KillProc(killhy)
end if
Next
end function
'杀死进程
Function KillProc(strProcName)
On Error Resume Next
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set arrProcesses = objWMIService.ExecQuery( "select * from win32_process where Name ='"&strProcName&"'" )
For Each proccess In arrProcesses
proccess.Terminate 0
Next
End Function
页:
[1]