Created
May 28, 2012 03:45
-
-
Save theagreeablecow/2817116 to your computer and use it in GitHub Desktop.
Process List and Kill
This file contains 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
' Produces list of process info from a remote computer. Optionally kill a running process based on PID. | |
' Requires PsList and PsKill from PsTools http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx | |
' TheAgreeableCow 2012 | |
dim objShell : Set objShell = WScript.CreateObject ("WScript.shell") | |
dim fileSys : Set fileSys = CreateObject("Scripting.FileSystemObject") | |
dim strComputer, strCMD, strLog, intAnswer, strProcess, strBatchFile, strDate | |
strComputer = InputBox("Enter name of Server/PC to capture process list") | |
strBatchFile = "C:\PSTools\pslist.bat" | |
strDate = replace (Date(),"/","-") | |
strLog = "C:\PSTools\" & strComputer & "_" & strDate & ".txt" | |
'Get PC process list and write to log file | |
if strComputer = "" then | |
wscript.echo "No PC entered" | |
wscript.quit | |
else | |
dim fileOut : Set fileOut = fileSys.CreateTextFile(strBatchFile, True) | |
fileOut.WriteLine "pslist.exe \\" & strComputer & " -s 10 -r 2 -m>" & strLog | |
fileOut.Close | |
Set wShell = CreateObject("WScript.Shell") | |
wShell.Run strBatchFile, 1, TRUE | |
Set fil = fileSys.GetFile(strBatchFile) | |
fil.Delete | |
objShell.Run("notepad " & strLog) | |
end if | |
'Optionally kill a running process | |
intAnswer = Msgbox("Do you want to end a process on " & strComputer & "?", vbYesNo, "Kill Process?") | |
If intAnswer = vbYes Then | |
strProcess = InputBox("Enter process ID number") | |
strCMD = "pskill.exe \\" & strComputer & " " & strProcess | |
objShell.run strCMD | |
Else | |
wscript.quit | |
End If | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment