windows 下重启进程的脚本

发布时间:2020-05-17编辑:脚本学堂
windows 下重启进程的脚本

windows 下重启进程的脚本
 

复制代码 代码如下:
strPName = "notepad.exe"
strComputer = "."
Set objshell = CreateObject("Wscript.Shell")
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!" & strComputer & "rootcimv2")
Set colProcessList = objWMIService.ExecQuery _
    ("Select * from Win32_Process Where Name = '" & strPName & "'")
For Each objProcess in colProcessList
    objProcess.Terminate()
Next
WScript.Sleep 2000
objshell.Run "c:windowssystem32notepad.exe"

注释
strPName 进程名
objshell run 进程路径