<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBS: Мониторинг процесса и действия над ним]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=7512&amp;type=atom" />
	<updated>2012-08-30T12:34:53Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=7512</id>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Мониторинг процесса и действия над ним]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=63336#p63336" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>smaharbA пишет:</cite><blockquote><p>and commandline like &#039;%-offline%&#039;</p></blockquote></div><p>Большое спасибо, все работает</p>]]></content>
			<author>
				<name><![CDATA[bear62]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=28580</uri>
			</author>
			<updated>2012-08-30T12:34:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=63336#p63336</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Мониторинг процесса и действия над ним]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=63331#p63331" />
			<content type="html"><![CDATA[<p>and commandline like &#039;%-offline%&#039;</p>]]></content>
			<author>
				<name><![CDATA[smaharbA]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=2911</uri>
			</author>
			<updated>2012-08-30T11:43:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=63331#p63331</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBS: Мониторинг процесса и действия над ним]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=63328#p63328" />
			<content type="html"><![CDATA[<p>Здравствуйте. <br />Помогите, пожалуйста, с написанием скрипта. <br />Задача:<br />Необходимо проверять доступность удаленного сервера и если пинг есть:<br />1)&nbsp; проверить в процессах наличие процесса с &quot;командой запуска&quot; firefox.exe -offline, <br />2) если такой процесс есть, &quot;убиваем&quot; процесс firefox.exe<br />3) запускаем firefox.exe<br />если пинга нет:<br />1) проверить в процессах наличие процесса с &quot;командой запуска&quot; firefox.exe -offline<br />2) если такого процесса нет, &quot;убиваем&quot; процесс firefox.exe<br />3) запускаем firefox.exe -offline</p><p>Вопрос в следующем, как в запросе в качестве условия указать &quot;CommandLine&quot; , сейчас по имени процесса все работает;<br />CommandLine в WinXP выглядит следующим образом:<br />&quot;C:\Program Files\Mozilla Firefox\firefox.exe&quot; -offline </p><p>Вот, что получилось:<br /></p><div class="codebox"><pre><code>if ping (&quot;ya.ru&quot;) then

Set objService = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2&quot;)

If objService.ExecQuery(&quot;SELECT * FROM Win32_Process WHERE Name = &#039;firefox.exe&#039;&quot;).Count = 1 Then
            For Each objProc In objService.ExecQuery(&quot;SELECT * FROM Win32_Process WHERE Name = &#039;firefox.exe&#039;&quot;)
    objProc.Terminate
    Next
            Set WshShell = CreateObject(&quot;WScript.Shell&quot;)
            WshShell.Run &quot;firefox.exe&quot;  
             Else

End if
else
Set objService = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2&quot;)

If objService.ExecQuery(&quot;SELECT * FROM Win32_Process WHERE Name = &#039;firefox.exe&#039;&quot;).Count = 1 Then
                 Else
    For Each objProc In objService.ExecQuery(&quot;SELECT * FROM Win32_Process WHERE Name = &#039;firefox.exe&#039;&quot;)
    objProc.Terminate             
     Set WshShell = CreateObject(&quot;WScript.Shell&quot;)
    WshShell.Run &quot;firefox.exe -offline&quot;  
    End If

Function Ping(strAddr)
&#039; Проверяем доступность компьютера с помощью команды PING 
        Set objShell = CreateObject(&quot;WScript.Shell&quot;)
        Set objScriptExec = objShell.Exec(&quot;%comspec% /c ping.exe -n 1 &quot; &amp; strAddr)
        strPingResults = LCase(objScriptExec.StdOut.ReadAll)
        Ping = InStr(strPingResults, &quot;ttl=&quot;)
        
End Function
End if</code></pre></div><p>Буду благодарен за любую помощь</p>]]></content>
			<author>
				<name><![CDATA[bear62]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=28580</uri>
			</author>
			<updated>2012-08-30T10:52:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=63328#p63328</id>
		</entry>
</feed>
