Print the running processes to a file (VBScript)

This code can be found in Chapter 1 of Windows Server Cookbook

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the VBScript code from this site.

' From the book "Windows Server Cookbook" by Robbie Allen
' ISBN: 0-596-00633-0

' ------ SCRIPT CONFIGURATION ------
strFile = "c:\output.txt" ' e.g. c:\output.txt
' ------ END CONFIGURATION ---------
const ForWriting = 2
set objFSO = CreateObject("Scripting.FileSystemObject")
set objFile = objFSO.OpenTextFile(strFile, ForWriting, True)
objFile.WriteLine("Script started: " & Now)
objFile.WriteLine("List of processes:")
set objWMI = GetObject("winmgmts:root\cimv2")
for each objProcess in objWMI.InstancesOf("Win32_Process")
	objFile.WriteLine(vbTab & objProcess.Name)
next

This code has been viewed 1845 times.

New from the creators of TechTasks.com: StatSheet.com