Option
Explicit
Private
Sub
Form_Load()
getProcessCommandLine
"
notepad.exe
"
End Sub
Private
Sub
getProcessCommandLine(ByVal proName
As
String
)
Dim
objWMIService
As
Object
Dim
colProcessList
As
Object
Dim
objProcess
As
Object
Dim
objProType
As
Object
Set
objWMIService
=
GetObject
(
"
winmgmts:
"
&
"
{impersonationlevel=impersonate}!\\.\root\cimv2
"
)
Set
colProcessList
=
objWMIService.ExecQuery(
"
Select * from Win32_Process Where Name='
"
&
proName
&
"
'
"
)
If
colProcessList.Count
<>
0
Then
For
Each
objProcess In colProcessList
For
Each
objProType In objProcess.Properties_
If
objProType.Name
=
"
CommandLine
"
Then
MsgBox objProType.Value
Exit
For
End
If
Next
Next
End
If
End Sub