<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; JScript: Скрипт для выполнения команды с админскими правами]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=9279&amp;type=atom" />
	<updated>2014-02-26T08:58:58Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=9279</id>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Скрипт для выполнения команды с админскими правами]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80386#p80386" />
			<content type="html"><![CDATA[<p>Решено!</p><div class="codebox"><pre><code>strComputer = &quot;имя машины&quot;

Set objSWbemLocator = CreateObject(&quot;WbemScripting.SWbemLocator&quot;)
Set objSWbemServices = objSWbemLocator.ConnectServer _ 
(strComputer, &quot;root\cimv2&quot;, _ 
&quot;ДОМЕН\юзер&quot;, &quot;12345&quot;)
Set colListOfServices = objSWbemServices.ExecQuery _
 (&quot;Select * from Win32_Service Where Name =&#039;имя службы&#039;&quot;)
For Each objService in colListOfServices
    objService.StopService()
    objService.ChangeStartMode(&quot;Disabled&quot;)
    WScript.Echo &quot;Stop and Disable Alerter service&quot;
    WScript.Quit 1
Next</code></pre></div><p>Замечания приветствуются!</p><p>К сожалению, как оказалось,из-за ограничений DCOM остановить/отключить службу под текущим пользователем используя другую учётку нельзя. Осталось автоматизировать процесс подстановки &quot;имя машины&quot;. Есть у кого есть какие мысли как это лучше сделать?</p><p>Огромное Спасибо <strong>alexii</strong> и <strong>Rom5</strong>!</p>]]></content>
			<author>
				<name><![CDATA[redserpent]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31818</uri>
			</author>
			<updated>2014-02-26T08:58:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80386#p80386</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Скрипт для выполнения команды с админскими правами]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80344#p80344" />
			<content type="html"><![CDATA[<p>спасибо огромное, сейчас буду разбираться!</p>]]></content>
			<author>
				<name><![CDATA[redserpent]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31818</uri>
			</author>
			<updated>2014-02-24T11:53:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80344#p80344</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Скрипт для выполнения команды с админскими правами]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80342#p80342" />
			<content type="html"><![CDATA[<p>На VBScript:<br /></p><div class="codebox"><pre><code>Option Explicit

Dim strComputer

Dim objSWbemLocator
Dim objSWbemServicesEx
Dim collSWbemObjectSet
Dim objSWbemObjectEx


strComputer = &quot;.&quot;

Set objSWbemLocator    = WScript.CreateObject(&quot;WbemScripting.SWbemLocator&quot;)
Set objSWbemServicesEx = objSWbemLocator.ConnectServer(strComputer, &quot;root\cimv2&quot;)
Set collSWbemObjectSet = objSWbemServicesEx.ExecQuery(&quot;SELECT * FROM Win32_Service WHERE Name = &#039;Messenger&#039;&quot;)

For Each objSWbemObjectEx In collSWbemObjectSet
    If Not objSWbemObjectEx.ChangeStartMode(&quot;Disabled&quot;) = 0 Then
        WScript.Echo &quot;Can&#039;t change start mode to [Disabled] for [Messenger] service.&quot;
        WScript.Quit 1
    End If
Next

Set collSWbemObjectSet = Nothing
Set objSWbemServicesEx = Nothing
Set objSWbemLocator    = Nothing

WScript.Quit 0
</code></pre></div><p>Вопросы?</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2014-02-24T11:21:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80342#p80342</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Скрипт для выполнения команды с админскими правами]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80341#p80341" />
			<content type="html"><![CDATA[<p>Т.е. мне нужен такой скрипт, который мог бы отключить службу на машине</p>]]></content>
			<author>
				<name><![CDATA[redserpent]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31818</uri>
			</author>
			<updated>2014-02-24T10:05:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80341#p80341</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Скрипт для выполнения команды с админскими правами]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80290#p80290" />
			<content type="html"><![CDATA[<p>Вы не поняли. Hе в SAMBA.&nbsp; Мне нужно разобраться как это реализовать с помощью WSH.</p>]]></content>
			<author>
				<name><![CDATA[redserpent]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31818</uri>
			</author>
			<updated>2014-02-22T21:31:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80290#p80290</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Скрипт для выполнения команды с админскими правами]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80288#p80288" />
			<content type="html"><![CDATA[<p><strong>redserpent</strong>, у меня нет ни малейшего представления, как это может выглядеть в SAMBA.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2014-02-22T21:23:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80288#p80288</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Скрипт для выполнения команды с админскими правами]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80285#p80285" />
			<content type="html"><![CDATA[<p>Большое спасибо за ответы, но как это скриптами сделать? От имени системы? Подскажите пожалуйста куда смотреть?</p>]]></content>
			<author>
				<name><![CDATA[redserpent]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31818</uri>
			</author>
			<updated>2014-02-22T20:04:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80285#p80285</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Скрипт для выполнения команды с админскими правами]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80282#p80282" />
			<content type="html"><![CDATA[<p>Я эту службу и хочу отключить через sc config. Но предварительно её нужно остановить. И для того и для другого требуются права уровня админских. Но выполнить их без запроса пароля, прозрачно на каждой машине вызвало у меня трудности, из-за ограничений &#039;runas&#039;. Как я уже писал, батник формируется для каждой машины при входе пользователя&nbsp; Perl скриптом. Этот скрипт смотрит в базу и подключает шары. Индивидуально для каждого.</p>]]></content>
			<author>
				<name><![CDATA[redserpent]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31818</uri>
			</author>
			<updated>2014-02-22T19:59:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80282#p80282</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Скрипт для выполнения команды с админскими правами]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80276#p80276" />
			<content type="html"><![CDATA[<p>Делайте это не от имени пользователя. Т.е., назначить это действие не на вход пользователя в систему:<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><p><span class="postimg"><img src="http://img18.imageshack.us/img18/6662/828h.png" alt="http://img18.imageshack.us/img18/6662/828h.png" /></span></p></div></div><p>а на сценарий автозагрузки, выполняемый от имени системы:<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><p><span class="postimg"><img src="http://img577.imageshack.us/img577/339/h5d0.png" alt="http://img577.imageshack.us/img577/339/h5d0.png" /></span></p></div></div><p>Мне другое непонятно — зачем делать остановку службы <em>каждый раз</em> вместо того, чтобы единожды раз поменять её параметры запуска на «Отключено» или «Вручную»?!</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2014-02-22T18:54:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80276#p80276</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Скрипт для выполнения команды с админскими правами]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80253#p80253" />
			<content type="html"><![CDATA[<p>SAMBA настроена так, что при аждом входе пользователей в домен у них автоматически срабатывает простой скрипт - батник. Батник выпоняет некоторые настроечные действия:&nbsp; net time, net us и р. Но эти действия не требуют админских прав. А вот чтобы глобально отключить какую-либо службу комадами net stop и sc config требуются администраторские права. А runas не позволяет просто передать пароль. Как минимум требебуется однократный ввод пароля. Это неприемлимо. Поэтому я стал смотреть в сторону WSH. Сам&nbsp; батник&nbsp; формирует Perl скрипт на сервере.</p>]]></content>
			<author>
				<name><![CDATA[redserpent]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31818</uri>
			</author>
			<updated>2014-02-21T16:37:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80253#p80253</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Скрипт для выполнения команды с админскими правами]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80245#p80245" />
			<content type="html"><![CDATA[<p><strong>redserpent</strong>, Вы бы объяснили глобальную цель сих действ.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2014-02-21T12:45:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80245#p80245</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Скрипт для выполнения команды с админскими правами]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80244#p80244" />
			<content type="html"><![CDATA[<p>Я да. Пользователи, соотвественно, ходят под своими обычными пользовательскими учётками. Но на машинах команда должна быть выполнена от имени пользователя, входящего в административную группу. Пользователи, разумеется, никаких паролей вводить не должны и действий с их стороны быть не должно. Всё долно быть атоматически</p>]]></content>
			<author>
				<name><![CDATA[redserpent]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31818</uri>
			</author>
			<updated>2014-02-21T12:43:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80244#p80244</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Скрипт для выполнения команды с админскими правами]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80243#p80243" />
			<content type="html"><![CDATA[<p><strong>redserpent</strong>, возможно, имелся в виду запуск пользователем скрипта, в котором автоматически передаются данные у/з с правами админа ?</p><br /><p>Тогда, по идее поможет подключение к WMI не через моникёр &quot;winmgmts:&quot;, а через &quot;SWbemLocator&quot; - и логин-пароль можно будет указать прямо в коде метода &quot;ConnectServer()&quot;:</p><p><a href="http://www.script-coding.com/WMI.html">http://www.script-coding.com/WMI.html</a> - <strong>&quot;Подключение к WMI в сценариях WSH с помощью объекта SWbemLocator&quot;</strong></p>]]></content>
			<author>
				<name><![CDATA[Rom5]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5724</uri>
			</author>
			<updated>2014-02-21T12:37:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80243#p80243</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Скрипт для выполнения команды с админскими правами]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80241#p80241" />
			<content type="html"><![CDATA[<p>А причём тут пользователь?! Вы — администратор?</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2014-02-21T11:05:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80241#p80241</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Скрипт для выполнения команды с админскими правами]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=80240#p80240" />
			<content type="html"><![CDATA[<p>А от имени admin этот метод можно будет приминить, не требуя от пользователя ввода паороля?</p>]]></content>
			<author>
				<name><![CDATA[redserpent]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31818</uri>
			</author>
			<updated>2014-02-21T10:56:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=80240#p80240</id>
		</entry>
</feed>
