8
« on: March 11, 2025, 04:24:43 PM »
Hi Kevin,
A script proposed by ChatGPT :
' VBScript to display command line of a specific process using Win32_Process class
Option Explicit
' Specify the process name here (e.g., "notepad.exe")
Dim processName
processName = "chrome.exe"
' Create WMI object to access system information
Dim objWMIService, colProcessList, objProcess
Dim strQuery
' Set the WMI query to get processes with the specified name
strQuery = "SELECT * FROM Win32_Process WHERE Name = '" & processName & "'"
' Connect to WMI service
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
' Execute the query and get the collection of processes
Set colProcessList = objWMIService.ExecQuery(strQuery)
' Check if any processes were found
If colProcessList.Count = 0 Then
WScript.Echo "No processes found with the name: " & processName
Else
' Loop through each process and display its command line
For Each objProcess In colProcessList
WScript.Echo "Process ID: " & objProcess.ProcessID
WScript.Echo "Command Line: " & objProcess.CommandLine
WScript.Echo "-------------------------"
Next
End If
' Cleanup
Set objWMIService = Nothing
Set colProcessList = Nothing
Executing the script :
cscript cmdline.vbs