<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBS: Не работает подписка на события WMI]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6300&amp;type=atom" />
	<updated>2011-10-09T07:02:02Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=6300</id>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Не работает подписка на события WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=52315#p52315" />
			<content type="html"><![CDATA[<p>Попробуй <a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;id=7684">этот скрипт</a>. Исходник не выкладываю - 30000 строчек <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" />.</p>]]></content>
			<author>
				<name><![CDATA[dab00]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27085</uri>
			</author>
			<updated>2011-10-09T07:02:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=52315#p52315</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Не работает подписка на события WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=52287#p52287" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>dab00 пишет:</cite><blockquote><p>пост на этом форуме.</p></blockquote></div><p>Про пост знаю, применил несколько рецептов, даже переустановил WMI, как рекомендовано <strong>Евген</strong>.&nbsp; Брандмауэр отключен, скрипт должен выполняться на локальной машине - все равно не работает. Похоже загвоздка в разрешениях провайдера CommandLineEventConsumer, потому что провайдер LogFileEventConsumer работает как ему и положено. А вот как настроить систему, чтобы &quot;освободить&quot; CommandLineEventConsumer, мне неясно.</p>]]></content>
			<author>
				<name><![CDATA[Poltergeyst]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=83</uri>
			</author>
			<updated>2011-10-08T10:11:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=52287#p52287</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Не работает подписка на события WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=52284#p52284" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Poltergeyst пишет:</cite><blockquote><p>Возможно, сложность проявляется в каких-то настройках безопасности, вот не могу понять в каких.</p></blockquote></div><p>По этому вопросу есть <a href="http://forum.script-coding.com/viewtopic.php?id=738">пост на этом форуме</a>.</p>]]></content>
			<author>
				<name><![CDATA[dab00]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27085</uri>
			</author>
			<updated>2011-10-08T09:34:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=52284#p52284</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Не работает подписка на события WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=52278#p52278" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>dab00 пишет:</cite><blockquote><p>Вот так можно:</p></blockquote></div><p>Это понятно, однако интересует именно постоянная подписка. Возможно, сложность проявляется в каких-то настройках безопасности, вот не могу понять в каких.</p>]]></content>
			<author>
				<name><![CDATA[Poltergeyst]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=83</uri>
			</author>
			<updated>2011-10-08T07:41:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=52278#p52278</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Не работает подписка на события WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=52276#p52276" />
			<content type="html"><![CDATA[<p>Вот так можно:<br /></p><div class="codebox"><pre><code>Set objWMI = GetObject(&quot;winmgmts:\\.\Root\CIMV2&quot;)
&#039;собираем запрос, WITHIN 2 - интервал повторения запроса в секундах
    Set colMonEvents = objWMI.ExecNotificationQuery(&quot;SELECT * FROM __InstanceCreationEvent &quot; _
            &amp; &quot;WITHIN 2 WHERE Targetinstance ISA &#039;Win32_DiskDrive&#039; and TargetInstance.InterfaceType = &#039;USB&#039;&quot;)     
    Do &#039;зацикливаем на заявленный интервал
        Set objLatestEvent = colMonEvents.NextEvent
        MsgBox &quot;Here I go!&quot;        
    Loop</code></pre></div>]]></content>
			<author>
				<name><![CDATA[dab00]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27085</uri>
			</author>
			<updated>2011-10-08T05:28:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=52276#p52276</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Не работает подписка на события WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=52274#p52274" />
			<content type="html"><![CDATA[<p><a href="http://da440dil.narod.ru/scripts.html">Здесь</a> посмотрите про USB <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" />, &quot;событие вставки USB-flash накопителя&quot; успешно ловится.</p>]]></content>
			<author>
				<name><![CDATA[dab00]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27085</uri>
			</author>
			<updated>2011-10-08T04:36:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=52274#p52274</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBS: Не работает подписка на события WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=52259#p52259" />
			<content type="html"><![CDATA[<p>Нижеуказанный код постоянной подписки на событие WMI использует в качестве потребителя CommandLineEventConsumer.</p><p>VBScript:<br /></p><div class="codebox"><pre><code>Set objService = GetObject(&quot;WINMGMTS:{impersonationLevel=Impersonate}!\\.\ROOT\CIMV2&quot;)

&#039;/Создание фильтра событий(вставка USB-накопителя)/
&#039;---------------------------------------------------------------------------
Set objFilter = objService.Get(&quot;__EventFilter&quot;).SpawnInstance_()

With objFilter
    .Name = &quot;MyEvent&quot;
    .QueryLanguage = &quot;WQL&quot;
    .EventNamespace = &quot;ROOT\CIMV2&quot;
    .Query = &quot;SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA &#039;Win32_LogicalDisk&#039; AND TargetInstance.DriveType=2&quot;
    Set objFilterPath = .Put_()
    .Put_()
End With


&#039;/Потребитель событий/
&#039;---------------------------------------------------------------------------
Set objConsumer = objService.Get(&quot;CommandLineEventConsumer&quot;).SpawnInstance_()

With objConsumer
    .Name = &quot;MyEventCallback&quot;
    .CommandLineTemplate = &quot;cmd.exe /c calc&quot;
    .RunInteractively = True
    .WorkingDirectory = &quot;C:\WINDOWS\SYSTEM32\&quot;
    Set objConsumerPath = .Put_()
End With

&#039;/Связка фильтра и потребителя/
&#039;---------------------------------------------------------------------------
Set objBinding = objService.Get(&quot;__FilterToConsumerBinding&quot;).SpawnInstance_()

With objBinding
    .Filter = objFilterPath
    .Consumer = objConsumerPath
    .Put_()
End With

MsgBox &quot;Подписка&quot; &amp; vbCRLF &amp; _
    objFilterPath.Path &amp; vbCRLF &amp; _
    objConsumerPath.Path, vbSystemModal + vbInformation, &quot;Subscribe&quot;</code></pre></div><p>При возникновении события вставки USB-flash накопителя должен создаваться новый процесс прописанный в параметрах экземпляра CommandLineEventConsumer. Однако ничего не работает, а в протокол выводится следующее: </p><p><strong>wbemcore.log</strong><br /></p><div class="quotebox"><blockquote><p>GetUserDefaultLCID failed, restorting to system verion</p></blockquote></div><p><strong>wbemess.log</strong><br /></p><div class="quotebox"><blockquote><p>Could not determine logged on user<br />Failed to CreateProcess cmd.exe /c calc. Error 0x80041001<br />Dropping event destined for event consumer CommandLineEventConsumer=&quot;MyEventCallback&quot; in namespace //./root/CIMV2<br />Failed to deliver an event to event consumer CommandLineEventConsumer=&quot;MyEventCallback&quot; with error code 0x80041001. Dropping event.</p></blockquote></div><p>В системе под учетной записью администратора, WinXP. Файлы scrcons.mof, wbemcons.mof - скомпиллированы. </p><p>Подскажите, в чем может заключаться причина неработоспособности скрипта?</p>]]></content>
			<author>
				<name><![CDATA[Poltergeyst]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=83</uri>
			</author>
			<updated>2011-10-07T16:49:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=52259#p52259</id>
		</entry>
</feed>
