Last active
December 20, 2015 19:49
-
-
Save tyru/6185777 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
On Error Resume Next | |
Dim strProcName ' 終了するプロセス名 | |
Dim objProcList ' プロセス一覧 | |
Dim objProcess ' プロセス情報 | |
Dim lngKillNum ' 終了したプロセス数 | |
strProcName = "explorer.exe" | |
lngKillNum = 0 | |
Set objProcList = GetObject("winmgmts:").InstancesOf("win32_process") | |
For Each objProcess In objProcList | |
If LCase(objProcess.Name) = strProcName Then | |
objProcess.Terminate | |
If Err.Number = 0 Then | |
lngKillNum = lngKillNum + 1 | |
Else | |
WScript.Echo "エラー: " & Err.Description | |
End If | |
End If | |
Next | |
If lngKillNum > 0 Then | |
' WScript.Echo strProcName & " を " & lngKillNum & " 個強制終了しました。" | |
Else | |
WScript.Echo strProcName & " が見つかりませんでした。" | |
End If | |
Set objProcList = Nothing | |
Dim oShell | |
Set oShell = WScript.CreateObject ("WSCript.shell") | |
oShell.run "explorer.exe" | |
Set oShell = Nothing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment