Torgeir
Wed Jul 21 04:16:55 CDT 2004
Michael Harris (MVP) wrote:
> Yong Huang wrote:
>
>>I use this code to look at properties of a process
>>
>>Set objWMIService = GetObject("winmgmts:" & _
>>"{impersonationLevel=Impersonate}!\\" & strComputer & "\root\cimv2")
>>Set colItems = objWMIService.ExecQuery("Select * from Win32_Process
>>...")
>>For Each objItem in colItems
>> Wscript.Echo objItem.Name
>>...
>>
>>The Name or Caption property shows the command such as notepad.exe.
>>ExecutablePath shows the full path. If the process is "notepad
>>myfile.txt", how do I see "myfile.txt"? I looked at all properties of
>>Win32_process and none shows that info. Thanks for help.
>
>
>
> For XP and higher...
>
> Win32_Process.CommandLine
>
> Win32_Process
>
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_process.asp
And for Windows 2000:
For Win2k, if you want to get to the command line property for
a process, you can use tlist.exe in the Win2k "Support Tools".
If you run "tlist.exe <pid>", it will be listed for the process
with that PID. From a VBScript, you would need to parse this output.
E.g. here is the output for AutoItX's help file process running on my
computer just now:
C:\>tlist 2428
2428 hh.exe AutoItX Help
CWD: F:\wsh\AutoItX\AutoItX\
CmdLine: "C:\WINNT\hh.exe" F:\wsh\AutoItX\AutoItX\AutoItX.chm
(snip)
tlist .exe for Win2k is in the Support Tools found on the Win2k CD,
\Support\Tools\Suptools.msi, or for the latest version of
Support Tools (should work on non-SP4 computers as well):
http://www.microsoft.com/windows2000/downloads/servicepacks/sp4/supporttools.asp
--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx