<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBA создание процесса WMI]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6780&amp;type=atom" />
	<updated>2012-02-07T12:47:24Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=6780</id>
		<entry>
			<title type="html"><![CDATA[Re: VBA создание процесса WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=56534#p56534" />
			<content type="html"><![CDATA[<p>Благодарствую, буду пробовать.<br />По поводу интерактивности - оно и не требовалось, как раз юзверям мешать и не надо <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[jwalk]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27568</uri>
			</author>
			<updated>2012-02-07T12:47:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=56534#p56534</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBA создание процесса WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=56516#p56516" />
			<content type="html"><![CDATA[<p>Пример:<br /></p><div class="codebox"><pre><code>Const IMPERSONATE = 3
Set objLocator = CreateObject(&quot;WbemScripting.SWbemLocator&quot;)
Set objService = objLocator.ConnectServer(strComputer, &quot;root\cimv2&quot;, strDomain &amp; &quot;\&quot; &amp; strUser, strUserPass)
objService.Security_.ImpersonationLevel = IMPERSONATE
Set objInstance = objService.Get(&quot;Win32_Process&quot;)
intResult = objInstance.Create(strProcess, Null, Null, intProcID)</code></pre></div><p>Учтите, что с помощью класса <span style="color: red">Win32_Process</span> невозможно запустить интерактивный процесс на удалённой станции.<br />Сам-то процесс запустится, но текущий пользователь удалённой станции не сможет с ним взаимодействовать.<br />Для запуска интерактивного процесса необходимо использовать планировщик, то есть класс <span style="color: green">Win32_ScheduledJob</span>.</p>]]></content>
			<author>
				<name><![CDATA[Dmitrii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=13351</uri>
			</author>
			<updated>2012-02-07T06:09:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=56516#p56516</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBA создание процесса WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=56515#p56515" />
			<content type="html"><![CDATA[<p>т.е. <br /></p><div class="codebox"><pre><code>Set objWMIService = GetObject(&quot;winmgmts:&quot; _
    &amp; &quot;{impersonationLevel=impersonate}!\\&quot; _
    &amp; strComputer &amp; &quot;\root\cimv2&quot;, user, pass)</code></pre></div><p>?<br />Тогда ругается, что у GetObject слишком много параметров.</p>]]></content>
			<author>
				<name><![CDATA[jwalk]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27568</uri>
			</author>
			<updated>2012-02-07T04:27:22Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=56515#p56515</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBA создание процесса WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=56514#p56514" />
			<content type="html"><![CDATA[<p>можешь, точно так же как и в первом скрипте</p>]]></content>
			<author>
				<name><![CDATA[smaharbA]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=2911</uri>
			</author>
			<updated>2012-02-07T02:50:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=56514#p56514</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBA создание процесса WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=56513#p56513" />
			<content type="html"><![CDATA[<p>Собсно есть код, простой как 3 копейки. <br /></p><div class="codebox"><pre><code>Const SW_NORMAL = 1
strComputer = &quot;.&quot;          &#039;локальная машина
strCommand = &quot;Notepad.exe&quot; 
Set objWMIService = GetObject(&quot;winmgmts:&quot; _
    &amp; &quot;{impersonationLevel=impersonate}!\\&quot; _
    &amp; strComputer &amp; &quot;\root\cimv2&quot;)

&#039; настройка окна для показа блокнота
Set objStartup = objWMIService.Get(&quot;Win32_ProcessStartup&quot;)
Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = SW_NORMAL

&#039; создаем блокнот через Win32_Process
Set objProcess = objWMIService.Get(&quot;Win32_Process&quot;)
intReturn = objProcess.Create _
    (strCommand, Null, objConfig, intProcessID)
If intReturn &lt;&gt; 0 Then
    Wscript.Echo &quot;Process could not be created.&quot; &amp; _
        vbNewLine &amp; &quot;Command line: &quot; &amp; strCommand &amp; _
        vbNewLine &amp; &quot;Return value: &quot; &amp; intReturn
Else
    Wscript.Echo &quot;Process created.&quot; &amp; _
        vbNewLine &amp; &quot;Command line: &quot; &amp; strCommand &amp; _
        vbNewLine &amp; &quot;Process ID: &quot; &amp; intProcessID
End If</code></pre></div><p>Нужно выполнить его на удаленной машине, на что он ругается, кричит про доступ и GetObject, и это логично. На удаленной машине используется учетка отличная от моей, и комп не в домене. Покопавшись нашел что-то близкое, по идее: <br /></p><div class="codebox"><pre><code>strComputer = &quot;acapulco&quot; &#039;name of a remote computer
wmiNS = &quot;\root\cimv2&quot;
wmiClass = &quot;win32_NetworkProtocol&quot;
wmiWhere = &quot; where name like &#039;%TCP/IP%&#039;&quot;
wmiQuery = &quot;Select * from &quot; &amp; wmiClass &amp; wmiWhere
[b]strUsr =&quot;nwtraders\LondonAdmin&quot;&#039;Domain\Username
strPWD = &quot;P@ssw0rd&quot;&#039;UserNames password[/b]
Set objLocator = CreateObject(&quot;WbemScripting.SWbemLocator&quot;)
Set objWMIService = objLocator.ConnectServer(strComputer, wmiNS, _
strUsr, strPWD)
Set colItems = objWMIService.ExecQuery(wmiQuery)</code></pre></div><p>Но, к сожалению, тут подключение идет через SWbemLocator, в виду чего для запуска процесса я потом не могу использовать objWMIService, как быть?</p>]]></content>
			<author>
				<name><![CDATA[jwalk]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27568</uri>
			</author>
			<updated>2012-02-06T19:52:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=56513#p56513</id>
		</entry>
</feed>
