|
Finding Running Processes On A Remote Computer |
|
|
|
|
Written by Cheyenne Harden
|
|
Do you ever need to find out what processes are running on a remote machine? I do, so here is a script that will query a remote computer and write all processes to a text file.
----------COPY EVERYTHING BELOW THIS LINE----------
Dim objWMIService, objProcess, colProcess, fso, objFSO1, objFile, objFolder Dim strComputer, strList, strWritePath, textFile, strFile, strDirectory, i Const OPEN_FILE_FOR_WRITING = 2 strComputer = inputbox("Enter Computer Name Here.") strFile = strComputer &".txt" strWritePath = "\\SERVER\files\Scripts\" & strFile strDirectory = "\\SERVER\files\Scripts\" i = 0
'#########
Set objFSO1 = CreateObject("Scripting.FileSystemObject")
If objFSO1.FileExists("\\SERVER\files\Scripts\" & strFile) Then Set objFolder = objFSO1.GetFile("\\SERVER\files\Scripts\" & strFile)
Else Set objFile = objFSO1.CreateTextFile(strDirectory & strFile) 'Wscript.Echo "Just created " & objFolder & "\" & strFile objFile = ""
End If
'#########
If strComputer > "" Then Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2")
Set fso = CreateObject("Scripting.FileSystemObject") Set textFile = fso.OpenTextFile(strWritePath, OPEN_FILE_FOR_WRITING)
Set colProcess = objWMIService.ExecQuery _ ("Select * from Win32_Process")
For Each objProcess in colProcess strList = strList & i & " " & objProcess.Name & vbCrLf i = i + 1 Next
textFile.WriteLine(strList) Wscript.Echo strList
Wscript.Echo "Done..." Else End If WScript.Quit
----------COPY EVERYTHING ABOVE THIS LINE----------
PLEASE MAKE SURE NO WORD WRAPPING IS HAPPENING IN YOUR NOTEPAD!!! Make sure you replace \\SERVER\files\Scripts\ with your UNC server path which you want to log to.
*Make sure that you have write ability to the file path.
This information is provided "AS IS" with no warranties expressed or implied.
|