Jump to content

Recommended Posts

Posted

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

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...