<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: найти PID процесса по CommandLine]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=13321&amp;type=atom" />
	<updated>2017-12-23T12:22:23Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=13321</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: найти PID процесса по CommandLine]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122502#p122502" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[OmTatSat]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33453</uri>
			</author>
			<updated>2017-12-23T12:22:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122502#p122502</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: найти PID процесса по CommandLine]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122501#p122501" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[OmTatSat]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33453</uri>
			</author>
			<updated>2017-12-23T09:13:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122501#p122501</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: найти PID процесса по CommandLine]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122500#p122500" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[OmTatSat]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33453</uri>
			</author>
			<updated>2017-12-23T09:00:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122500#p122500</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: найти PID процесса по CommandLine]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=122498#p122498" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[OmTatSat]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33453</uri>
			</author>
			<updated>2017-12-22T23:51:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=122498#p122498</id>
		</entry>
</feed>
