Jump to content
Sign in to follow this  

how to get the process comands line by process pid

Recommended Posts


Hello my friends
I have an inquiry after your permission
I found a function to get the special line commands for any operation
It requires the name of the process to be searched
I want to use it to know the process
Is this possible with this function
Here is the code


Func commandLineGet($proc, $strComputer=".")
dim $array[1]
local $ArrayNumber
local $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
local $oProcessColl = $oWMI.ExecQuery("Select * from Win32_Process where Name= " & '"'& $Proc & '"')
local $Process
For $Process In $oProcessColl
$Process = $Process.Commandline
    ReDim $Array[UBound($Array)+1]
$ArrayNumber = UBound($Array)-1
$array[$ArrayNumber] = $Process
$ArrayNumber = UBound($Array)-1
$array[0] = $ArrayNumber
return $array

Edited by nacerbaaziz

Share this post

Link to post
Share on other sites


Share this post

Link to post
Share on other sites

the _WinAPI_GetProcessCommandLine  Require the admin PRIVILEGES
if there is an other solition please give it to me
thank you

Share this post

Link to post
Share on other sites

i reTryed this but it not give me the command line switches


#include <Array.au3>
#include <WinAPI.au3>
#include <WinAPIProc.au3>

Local $aAdjust, $aList = 0

; Enable "SeDebugPrivilege" privilege for obtain full access rights to another processes
Local $hToken = _WinAPI_OpenProcessToken(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))

_WinAPI_AdjustTokenPrivileges($hToken, $SE_DEBUG_NAME, $SE_PRIVILEGE_ENABLED, $aAdjust)

; Retrieve command-line arguments for all processes the system
If Not (@error Or @extended) Then
msgBox(64, "command line", _WinAPI_GetProcessCommandLine(9408))

; Enable SeDebugPrivilege privilege by default
_WinAPI_AdjustTokenPrivileges($hToken, $aAdjust, 0, $aAdjust)


where is the error please

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Similar Content

    • dadalt
      By dadalt
      I have a button where I need to close it!
      I was doing through  clicking same position in screen but there are some id's that have different sizes.
      What are the possible ways to click this closable button?
      Is there a way to close it through id? Is there a way to get it's position through it's ID?  
      Thanks in advance!

    • simy8891
      By simy8891
      Hi guys,
      It's been a while since I wrote my last message here and a while since I used AutoIt. I'm currently sort of desperate and I'm trying to find some help in regards of getting the network usage per process!
      I'm not interested in the total network usage of the NIC, but only on a specific PID's network utilization. They idea is to collect the amount of traffic uploaded and downloaded by a list of specific processes. So far Process Hacker and Process Explorer are capable of getting what I need, but I need to use these numbers in another script so they're sort of useless to me. I can't seem to find a way around it.
      Any idea, help is greatly appreciated.
    • ur
      By ur
      with the below code, I am keeping waiting for a particular file and waiting in the background.
      While $i <> 10 Sleep(60000) If FileExists(@ScriptDir&"\Binaries.ini") then --some processing-- $i = 10 endif WEnd I thought keeping the Sleep will freeze the process from resources but the CPU being uilized.But it is taking 47%.
      How to free this CPU usage also.?

    • BlazerV60
      By BlazerV60
      Hello all,
      I've written the code below which launches chrome in incognito mode and then proceeds to go to the autoit website.
      From my understanding, the Run() command is also supposed to output the PID number related to the application that got launched from the Run command.
      However when I run the below lines, it outputs a PID number that is different from the newly launched chrome browser's PID number, does anyone know why and possibly explain how I could retrieve the accurate PID number associated with the newly launched browser?
      Global $iPid = Run(@ComSpec & ' /c start chrome.exe https://www.autoitscript.com/forum/ -incognito' ,"", "") msgbox(0,"",$iPid) Thank you,
    • ur
      By ur
      With  ProcessList ( ["name"] )  we are able to get the running process list from the local machine.
      Is there anyway to get the list from Remote machine, more precisely to get to know the status whether a particular application is running or not on remote machine using AutoIT?
      We can implement through PSList.exe, but again we need to parse the text of it to read the output.
      Is there any direct UDF in AutoIT?

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.