<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: найти PID процесса по CommandLine]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=13321</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=13321&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: найти PID процесса по CommandLine».]]></description>
		<lastBuildDate>Sat, 23 Dec 2017 12:22:23 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: найти PID процесса по CommandLine]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=122502#p122502</link>
			<description><![CDATA[<p>Нашлось решение<br /></p><div class="codebox"><pre><code>for k in ComObjGet(&quot;winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2&quot;).ExecQuery(&quot;Select * from Win32_Process Where CommandLine like &#039;%--type=nacl-loader --service-request-channel-token%&#039;&quot;)


  MsgBox % k.ProcessId &quot;`n&quot; k.CommandLine</code></pre></div><p>Помогла статья https://blogs.technet.microsoft.com/heyscriptingguy/2012/07/13/use-the-like-operator-to-simplify-your-wql-queries/</p>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Sat, 23 Dec 2017 12:22:23 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=122502#p122502</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: найти PID процесса по CommandLine]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=122501#p122501</link>
			<description><![CDATA[<div class="codebox"><pre><code>for k in ComObjGet(&quot;winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2&quot;).ExecQuery(&quot;Select * from Win32_Process Where CommandLine = &#039;--type=nacl-loader&#039;&quot;)


  MsgBox % k.ProcessId &quot;`n&quot; k.CommandLine</code></pre></div><p>- не работает</p><p>Но <br /></p><div class="codebox"><pre><code>for k in ComObjGet(&quot;winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2&quot;).ExecQuery(&quot;Select * from Win32_Process Where ProcessId = &#039;5884&#039;&quot;)


  MsgBox % k.ProcessId &quot;`n&quot; k.CommandLine</code></pre></div><p>Работает, как можно сделать чтобы работало с CommandLine?</p>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Sat, 23 Dec 2017 09:13:57 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=122501#p122501</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: найти PID процесса по CommandLine]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=122500#p122500</link>
			<description><![CDATA[<p>Вот такое нашлось<br /></p><div class="codebox"><pre><code>for k in ComObjGet(&quot;winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2&quot;).ExecQuery(&quot;Select * from Win32_Process Where Name = &#039;chrome.exe&#039;&quot;)

If k.CommandLine(&quot;nacl&quot;)
{
  MsgBox % k.ProcessId &quot;`n&quot; k.CommandLine
}</code></pre></div><p>Только почему-то msgbox выводит все процессы chrome.exe а не только тот в котором команда nacl. Как это можно исправить?</p>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Sat, 23 Dec 2017 09:00:24 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=122500#p122500</guid>
		</item>
		<item>
			<title><![CDATA[AHK: найти PID процесса по CommandLine]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=122498#p122498</link>
			<description><![CDATA[<p>Есть chrome, он имеет много процессов на время нужно останавливать процесс у которого известно комманду запуска.</p><br /><div class="codebox"><pre><code>chrome.exe	&quot;C:\Users\Sat\AppData\Local\Chromium\Application\chrome.exe&quot; --type=nacl-loader --service-request-channel-token=15AF08ACA73CB3C66A31E74BB7FF1500 --mojo-platform-channel-handle=6196 --ignored=&quot; --type=renderer &quot; /prefetch:8</code></pre></div><div class="codebox"><pre><code>nacl-loader</code></pre></div><p> - константа, по ней и думаю искать процесс.</p><p>Потом при клике на окно chrome нужно восстанавливать процесс.</p><div class="codebox"><pre><code>Gui, Add, ListView, x2 y0 w400 h500, Process Name|Command Line
for process in ComObjGet(&quot;winmgmts:&quot;).ExecQuery(&quot;Select * from Win32_Process&quot;)
    LV_Add(&quot;&quot;, process.ProcessId, process.CommandLine)
Gui, Show,, Process List</code></pre></div><p>Вот таким кодом получается увидеть и PID и команду запуска, но как найти строку с константой и использовать PID с неё?</p><p>Вот так думаю останавливать и запускать процесс</p><div class="codebox"><pre><code>Process_Resume(&quot;5884&quot;)

;============================== Working on WinXP+

Process_Suspend(PID_or_Name){

    PID := (InStr(PID_or_Name,&quot;.&quot;)) ? ProcExist(PID_or_Name) : PID_or_Name

    h:=DllCall(&quot;OpenProcess&quot;, &quot;uInt&quot;, 0x1F0FFF, &quot;Int&quot;, 0, &quot;Int&quot;, pid)

    If !h   

        Return -1

    DllCall(&quot;ntdll.dll\NtSuspendProcess&quot;, &quot;Int&quot;, h)

    DllCall(&quot;CloseHandle&quot;, &quot;Int&quot;, h)

}

Process_Resume(PID_or_Name){

    PID := (InStr(PID_or_Name,&quot;.&quot;)) ? ProcExist(PID_or_Name) : PID_or_Name

    h:=DllCall(&quot;OpenProcess&quot;, &quot;uInt&quot;, 0x1F0FFF, &quot;Int&quot;, 0, &quot;Int&quot;, pid)

    If !h   

        Return -1

    DllCall(&quot;ntdll.dll\NtResumeProcess&quot;, &quot;Int&quot;, h)

    DllCall(&quot;CloseHandle&quot;, &quot;Int&quot;, h)

}

ProcExist(PID_or_Name=&quot;&quot;){

    Process, Exist, % (PID_or_Name=&quot;&quot;) ? DllCall(&quot;GetCurrentProcessID&quot;) : PID_or_Name

    Return Errorlevel

}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (OmTatSat)]]></author>
			<pubDate>Fri, 22 Dec 2017 23:51:36 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=122498#p122498</guid>
		</item>
	</channel>
</rss>
