NIM Posted August 22, 2006 Share Posted August 22, 2006 Dim objWMIService, objProcess, colProcess, fso, objFSO1, objFile, objFolderDim strComputer, strList, strWritePath, textFile, strFile, strDirectory, iConst OPEN_FILE_FOR_WRITING = 2strComputer = inputbox("Enter Computer Name Here.")strFile = strComputer &".txt"strWritePath = "\\SERVER\files\Scripts\" & strFilestrDirectory = "\\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 > "" ThenSet 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 colProcessstrList = strList & i & " " & objProcess.Name & vbCrLfi = i + 1NexttextFile.WriteLine(strList)Wscript.Echo strListWscript.Echo "Done..."ElseEnd IfWScript.QuitPLEASE 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.