'Get all the processes of Your PC and out put to text file
Function getRunningProcessList(strComputer) ' if no computer name is specified, run on local machine If Len(strComputer) = 0 Then strComputer = Environment("LocalHostName") End If
On Error Resume Next Dim ProcessSet ' get list of running processes from Windows Management Instrumentation Set ProcessSet = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2").ExecQuery("select * from Win32_Process") If (Not Err.Number = 0) Then getRunningProcessList = "Could not get process list for computer " & strComputer & vbCrLf & vbCrLf & "Error " & Err.Number & " " & Err.Description Exit Function End If
' build a textual description of running processes Dim strProcessList strProcessList = "Processes running on computer " & strComputer & ":" & vbCrLf & vbCrLf strProcessList = strProcessList & "Description" & vbTab & vbTab & "Executable Path" & vbCrLf strProcessList = strProcessList & "===========" & vbTab & vbTab & "===============" & vbCrLf & vbCrLf Dim Process For Each Process In ProcessSet strProcessList = strProcessList & Process.Description & vbTab & vbTab If Len(Process.Description) < 8 Then strProcessList = strProcessList & vbTab End If strProcessList = strProcessList & Process.ExecutablePath & vbCrLf Next
' return textual description of running processes getRunningProcessList = strProcessList End Function
Dim objFSO, objTextFile Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.CreateTextFile("c:\ProcessesList.txt", True) 'You need to send the name of Your pc instead "main" msgbox getRunningProcessList("main")
'It will write the list in C:\ProcessesList... objTextFile.WriteLine getRunningProcessList("main")
I can't compile it in MS Visual Studio .NET Does i need any special ?
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.