<?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=11575&amp;type=atom" />
	<updated>2016-05-12T08:34:42Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=11575</id>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Запись в лог загрузки процессора по конкретному процессу]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103683#p103683" />
			<content type="html"><![CDATA[<p><strong>Flasher</strong><br />Что активно крутилось на компе, то и вставил. С эксплорером счас буду пробовать.</p>]]></content>
			<author>
				<name><![CDATA[Alex Li]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33884</uri>
			</author>
			<updated>2016-05-12T08:34:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103683#p103683</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Запись в лог загрузки процессора по конкретному процессу]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103674#p103674" />
			<content type="html"><![CDATA[<p>Понял. Как-нибудь попробую на XP. А почему <em>isis</em> вместо <em>iexplore</em>?</p>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2016-05-11T21:35:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103674#p103674</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Запись в лог загрузки процессора по конкретному процессу]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103673#p103673" />
			<content type="html"><![CDATA[<p>Windows XP Sp3 , wscript 5.7</p>]]></content>
			<author>
				<name><![CDATA[Alex Li]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33884</uri>
			</author>
			<updated>2016-05-11T20:51:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103673#p103673</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Запись в лог загрузки процессора по конкретному процессу]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103671#p103671" />
			<content type="html"><![CDATA[<p>ОК. Можно и так. А какая версия Windows и wscript.exe (на всякий случай)?</p>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2016-05-11T20:18:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103671#p103671</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Запись в лог загрузки процессора по конкретному процессу]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103670#p103670" />
			<content type="html"><![CDATA[<p>Попробовал - другая ошибка - &quot;Недопустимое использование Null :&#039;CStr&#039;&quot;.Если без CStr вместо PerfProcess.PercentProcessorTime написать 1 или &quot;1&quot; - пишет в лог за милу душу.</p><p>Нашел&nbsp; &nbsp;<a href="http://&quot;http://www.vbforums.com/showthread.php?696637-Kill-Process-When-It-Becomes-Idle&amp;s=66a94804d2048e8e72df3d24c6420a25&amp;p=4267177&amp;viewfull=1#post4267177">тут </a> конструкцию через IF, попробовал - работает.<br />В результате код принял такой вид:</p><div class="codebox"><pre><code>
LogFile = &quot;C:\Log.txt&quot;

Set LogFile = CreateObject(&quot;Scripting.FileSystemObject&quot;).OpenTextFile(LogFile, 8, True)
Set PerfProcess = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2&quot;)._
Get(&quot;Win32_PerfFormattedData_PerfProc_Process.Name=&#039;isis&#039;&quot;)

Do
  PerfProcess.Refresh_()
If PerfProcess.PercentProcessorTime &gt; 0 Then
LogFile.WriteLine PerfProcess.PercentProcessorTime
else
LogFile.WriteLine 0
End If
WScript.Sleep 300  
Loop
</code></pre></div><p>Еще раз большое спасибо за помощь!</p>]]></content>
			<author>
				<name><![CDATA[Alex Li]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33884</uri>
			</author>
			<updated>2016-05-11T20:08:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103670#p103670</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Запись в лог загрузки процессора по конкретному процессу]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103630#p103630" />
			<content type="html"><![CDATA[<p>Я проверял, такой проблемы не было. Попробуйте добавить синее: <span style="color: blue"><strong>CStr(</strong></span>PerfProcess.PercentProcessorTime<span style="color: blue"><strong>)</strong></span>.</p><p><strong>P.S.:</strong> Двоеточие вместо точки в заголовке забыли.</p>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2016-05-11T05:37:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103630#p103630</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Запись в лог загрузки процессора по конкретному процессу]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103628#p103628" />
			<content type="html"><![CDATA[<p>Пишет &quot;Несоответствие типа LogFile.WriteLine&quot;</p>]]></content>
			<author>
				<name><![CDATA[Alex Li]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33884</uri>
			</author>
			<updated>2016-05-11T05:31:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103628#p103628</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Запись в лог загрузки процессора по конкретному процессу]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103623#p103623" />
			<content type="html"><![CDATA[<p>Исправьте в заголовке <strong>WBS.</strong> на <strong>VBS:</strong>.</p><div class="codebox"><pre><code>LogFile = &quot;C:\Log.txt&quot;

Set LogFile = CreateObject(&quot;Scripting.FileSystemObject&quot;).OpenTextFile(LogFile, 8, True)
Set PerfProcess = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2&quot;)._
Get(&quot;Win32_PerfFormattedData_PerfProc_Process.Name=&#039;iexplore&#039;&quot;)

Do
  PerfProcess.Refresh_     
  LogFile.WriteLine PerfProcess.PercentProcessorTime
  WScript.Sleep 300
Loop</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2016-05-10T23:38:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103623#p103623</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBS: Запись в лог загрузки процессора по конкретному процессу]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=103621#p103621" />
			<content type="html"><![CDATA[<p>Нужно записывать в лог загрузку процессора по процессу iexplore.exe - (7й Интернетэксплорер) - просто две цифры в лог каждые 0,3 сек</p><p>Нашел код </p><div class="codebox"><pre><code>
strComputer = &quot;.&quot;
Set objWMIService = GetObject(&quot;winmgmts:&quot; _
    &amp; &quot;{impersonationLevel=impersonate}!\\&quot; _
    &amp; strComputer &amp; &quot;\root\cimv2&quot;)
set PerfProcess = objWMIService.Get(_
    &quot;Win32_PerfFormattedData_PerfProc_Process.Name=&#039;Idle&#039;&quot;)

While (True)
    PerfProcess.Refresh_     
    Wscript.Echo PerfProcess.PercentProcessorTime
    Wscript.Sleep 1000
Wend
</code></pre></div><p>Как модифицировать этот код, чтобы вместо всплывающего окна была запись в лог? Спасибо!</p>]]></content>
			<author>
				<name><![CDATA[Alex Li]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33884</uri>
			</author>
			<updated>2016-05-10T20:48:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=103621#p103621</id>
		</entry>
</feed>
