Skip to content

Instantly share code, notes, and snippets.

@joenorton8014
Last active August 28, 2018 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joenorton8014/e11798f528350197d1133ccda2c6d96e to your computer and use it in GitHub Desktop.
Save joenorton8014/e11798f528350197d1133ccda2c6d96e to your computer and use it in GitHub Desktop.
Dim fso, objShell, objShellEnv, strComputerName, objFso, dt
dt = now
timestamp = ((year(dt)*100 + month(dt))*100 + day(dt))*10000 + hour(dt)*100 + minute(dt)
Set objShell = WScript.CreateObject("WScript.Shell")
Set objShellEnv = objShell.Environment("Process")
strComputerName = objShellEnv("ComputerName")
Set objFso = WScript.CreateObject("Scripting.FileSystemObject")
Set outputFile = objFso.CreateTextFile("C:\tools\allproc-" & timestamp & ".csv", True)
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_Process",,48)
outputFile.WriteLine "Name,CommandLine,CreationDate,Description,ExecutablePath"
For Each objItem in colItems
outputFile.WriteLine objItem.Name & "," & objItem.CommandLine & "," & objItem.CreationDate & "," & objItem.Description & "," & objItem.ExecutablePath
Next
outputFile.Close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment