<?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="http://forum.script-coding.com/extern.php?action=feed&amp;tid=17117&amp;type=atom" />
	<updated>2022-05-15T20:22:19Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=17117</id>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Изменение типа запуска службы и запуск службы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=153215#p153215" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, ok.</p>]]></content>
			<author>
				<name><![CDATA[biffick]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40335</uri>
			</author>
			<updated>2022-05-15T20:22:19Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=153215#p153215</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Изменение типа запуска службы и запуск службы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=153208#p153208" />
			<content type="html"><![CDATA[<p><strong>biffick</strong>, ознакомьтесь, пожалуйста, с <a href="https://forum.script-coding.com/misc.php?action=rules">Правилами</a>, отредактируйте свои посты. Обратите внимание на <a href="https://forum.script-coding.com/misc.php?action=rules#literacy">точки</a> в конце предложений.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-05-14T21:59:18Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=153208#p153208</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Изменение типа запуска службы и запуск службы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=153198#p153198" />
			<content type="html"><![CDATA[<p><strong>Rumata</strong>, благодарю, всё работает.</p>]]></content>
			<author>
				<name><![CDATA[biffick]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40335</uri>
			</author>
			<updated>2022-05-14T20:57:31Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=153198#p153198</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Изменение типа запуска службы и запуск службы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=153196#p153196" />
			<content type="html"><![CDATA[<p>Например, так:<br /></p><div class="codebox"><pre><code>
Set wmi = GetObject(&quot;winmgmts://./root/cimv2&quot;)

ServicesSetMode wmi, &quot;Manual&quot;, Array( _
	&quot;Bluetooth Device Monitor&quot;, _
	&quot;Bluetooth Media Service&quot;, _
	&quot;Bluetooth OBEX Service&quot;, _
	&quot;iBtSiva&quot;, _
	&quot;XperiaCompanionService&quot;, _
	&quot;TeamViewer&quot; )

ServicesSetMode wmi, &quot;Disabled&quot;, Array( _
	&quot;VMwareHostd&quot;, _
	&quot;VMUSBArbService&quot;, _
	&quot;VMware NAT Service&quot;, _
	&quot;VMnetDHCP&quot;, _
	&quot;VMAuthdService&quot; )

Sub ServicesSetMode(wmi, mode, names)
	Dim service
	For Each name in names
		Set service = wmi.Get(&quot;Win32_Service.Name=&#039;&quot; &amp; name &amp; &quot;&#039;&quot;)
		service.StopService
		service.ChangeStartMode(mode)
	Next
End Sub
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Rumata]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24846</uri>
			</author>
			<updated>2022-05-14T16:38:44Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=153196#p153196</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Изменение типа запуска службы и запуск службы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=153195#p153195" />
			<content type="html"><![CDATA[<p><strong>Rumata</strong>, здравствуйте. Понимал бы Visual Basic Script, на форум не лез бы.</p>]]></content>
			<author>
				<name><![CDATA[biffick]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40335</uri>
			</author>
			<updated>2022-05-14T16:10:53Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=153195#p153195</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Изменение типа запуска службы и запуск службы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=153194#p153194" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>biffick пишет:</cite><blockquote><p>я подправил скрипт</p></blockquote></div><p>У Вас два фактически идентичных цикла. Параметризуйте их и заверните в подпрограмму.</p>]]></content>
			<author>
				<name><![CDATA[Rumata]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24846</uri>
			</author>
			<updated>2022-05-14T15:50:42Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=153194#p153194</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Изменение типа запуска службы и запуск службы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=153193#p153193" />
			<content type="html"><![CDATA[<p><strong>andypetr</strong>, я подправил скрипт так, чтобы было удобно.<br />Результат:</p><div class="codebox"><pre><code>
&#039; Script &#039;Autorun Services Stop&#039;
&#039; 
&#039; Services use = StartService | StopService
&#039; ChangeStartMode = Boot | System | Automatic | Manual | Disabled
&#039; 
Set wmi = GetObject(&quot;winmgmts://./root/cimv2&quot;)
&#039; __________________________________________________________________
&#039; Services with Manual StartMode
&#039; 
For Each ManualStartMode In Array(&quot;Bluetooth Device Monitor&quot;, &quot;Bluetooth Media Service&quot;, &quot;Bluetooth OBEX Service&quot;, &quot;iBtSiva&quot;, &quot;XperiaCompanionService&quot;, &quot;TeamViewer&quot;)
&#039; 
&#039; Actions
&#039; 
With wmi.Get(&quot;Win32_Service.Name=&#039;&quot; &amp; ManualStartMode &amp; &quot;&#039;&quot;):.StopService:.ChangeStartMode(&quot;Manual&quot;):End With
Next
&#039; __________________________________________________________________
&#039; Services with Disabled StartMode
&#039; 
For Each DisabledStartMode In Array(&quot;VMwareHostd&quot;, &quot;VMUSBArbService&quot;, &quot;VMware NAT Service&quot;, &quot;VMnetDHCP&quot;, &quot;VMAuthdService&quot;)
&#039; 
&#039; Actions
&#039; 
With wmi.Get(&quot;Win32_Service.Name=&#039;&quot; &amp; DisabledStartMode &amp; &quot;&#039;&quot;):.StopService:.ChangeStartMode(&quot;Disabled&quot;):End With
Next
&#039; __________________________________________________________________
&#039; Quit
WScript.Quit
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[biffick]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40335</uri>
			</author>
			<updated>2022-05-14T14:37:57Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=153193#p153193</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Изменение типа запуска службы и запуск службы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=153192#p153192" />
			<content type="html"><![CDATA[<p>Вопрос, в общем-то, решён.<br />Спасибо <strong>andypetr</strong>!</p>]]></content>
			<author>
				<name><![CDATA[biffick]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40335</uri>
			</author>
			<updated>2022-05-14T13:08:29Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=153192#p153192</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Изменение типа запуска службы и запуск службы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=153185#p153185" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>andypetr пишет:</cite><blockquote><p>PS. Насчёт bat-файлов, не видя кода, ничего не могу сказать.<br />У меня команды SC и NET отрабатывают быстро (сразу отказ в доступе, т.к. нет прав администратора).</p></blockquote></div><p>Bat-ник медленно отрабатывает, потому что он ждёт запуска/остановки каждой службы.<br />В принципе, вот код bat-ника:</p><div class="codebox"><pre><code>
@echo off

rem Подсебятина
rem Цвет текста
color 0B
rem Пауза
set &quot;pause=1&gt;nul timeout /t 0 /nobreak&quot;
rem Показ ошибок
set &quot;errors=2&gt;nul&quot;
rem Показ информации
set &quot;info=1&gt;nul 2&gt;&amp;1&quot;


echo ==================================================
echo # ЗАПУСК VMWARE
echo ______________________________________

%pause%

echo Запуск службы &quot;VMAuthdService&quot;
sc config &quot;VMAuthdService&quot; start= demand
net start &quot;VMAuthdService&quot;
echo ______________________________________


echo Запуск службы &quot;VMnetDHCP&quot;
sc config &quot;VMnetDHCP&quot; start= demand
net start &quot;VMnetDHCP&quot;
echo ______________________________________


echo Запуск службы &quot;VMware NAT Service&quot;
sc config &quot;VMware NAT Service&quot; start= demand
net start &quot;VMware NAT Service&quot;
echo ______________________________________


echo Запуск службы &quot;VMUSBArbService&quot;
sc config &quot;VMUSBArbService&quot; start= demand
net start &quot;VMUSBArbService&quot;
echo ______________________________________


echo Запуск службы &quot;VMwareHostd&quot;
sc config &quot;VMwareHostd&quot; start= demand
net start &quot;VMwareHostd&quot;
echo ______________________________________


echo Запуск &quot;VMware Workstation Pro&quot;
%pause%
start &quot;&quot; &quot;vmware.exe&quot;

exit
</code></pre></div><p>Конечно же, этот bat-ник лежит в папке VMware.<br />Отрабатывает примерно за 5 секунд, в то время как VBS это делает менее чем за секунду.</p><p>По поводу вашего кода - VBS-ник пишется с запасом на будущее, т.е. не только под VMware и не только под ChangeStartMode(&quot;Manual&quot;), где-то будет &quot;Automatic&quot;, где-то другое.</p>]]></content>
			<author>
				<name><![CDATA[biffick]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40335</uri>
			</author>
			<updated>2022-05-13T05:31:46Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=153185#p153185</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Изменение типа запуска службы и запуск службы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=153184#p153184" />
			<content type="html"><![CDATA[<p>Более лаконично можно было бы так написать (внутри цикла For оставить один из двух вариантов):<br /></p><div class="codebox"><pre><code>Set wmi = GetObject(&quot;winmgmts://./root/cimv2&quot;)
&#039; 
&#039; VMware Mode and Start Services
&#039; 
For Each strName In Array(&quot;VMAuthdService&quot;, &quot;VMnetDHCP&quot;, &quot;VMware NAT Service&quot;, &quot;VMUSBArbService&quot;, &quot;VMwareHostd&quot;)
	
	&#039; 1 вариант:
	With wmi.Get(&quot;Win32_Service.Name=&#039;&quot; &amp; strName &amp; &quot;&#039;&quot;)
		.ChangeStartMode(&quot;Manual&quot;)
		.StartService
	End With
	
	&#039; 2 вариант (можно конструкцию With записать в одну строку):
	With wmi.Get(&quot;Win32_Service.Name=&#039;&quot; &amp; strName &amp; &quot;&#039;&quot;):.ChangeStartMode(&quot;Manual&quot;):.StartService:End With

Next
&#039; 
&#039; VMware Start Program
&#039; 
...
</code></pre></div><p><em>PS. Насчёт bat-файлов, не видя кода, ничего не могу сказать.<br />У меня команды SC и NET отрабатывают быстро (сразу отказ в доступе, т.к. нет прав администратора).</em></p>]]></content>
			<author>
				<name><![CDATA[andypetr]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40320</uri>
			</author>
			<updated>2022-05-13T03:35:26Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=153184#p153184</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Изменение типа запуска службы и запуск службы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=153183#p153183" />
			<content type="html"><![CDATA[<p>Почему bat&#039;ники отрабатывают такие же функции дольше, чем VBS, причём сильно дольше?<br />Bat&#039;ник запускает службу 2 секунды, а VBS это делает за доли секунды.<br />Может возможно как-то решить проблему, тогда VBS отпал бы вообще.</p>]]></content>
			<author>
				<name><![CDATA[biffick]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40335</uri>
			</author>
			<updated>2022-05-12T23:25:52Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=153183#p153183</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Изменение типа запуска службы и запуск службы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=153179#p153179" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>andypetr пишет:</cite><blockquote><p>Попробуйте &quot;расцепить&quot; вызовы функций:</p></blockquote></div><p>Здравствуйте. Если разъединить вызовы, то будет работать. Но хотелось бы, чтобы в одной строке всё было.</p>]]></content>
			<author>
				<name><![CDATA[biffick]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40335</uri>
			</author>
			<updated>2022-05-12T16:14:03Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=153179#p153179</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Изменение типа запуска службы и запуск службы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=153162#p153162" />
			<content type="html"><![CDATA[<p>Добрый день!<br /><em>VMware у меня нет, как и прав администратора на рабочем компе.</em><br />Попробуйте &quot;расцепить&quot; вызовы функций:<br /></p><div class="codebox"><pre><code>svc.ChangeStartMode(&quot;Manual&quot;)
svc.StartService
</code></pre></div><p>Скорее всего, ChangeStartMode() возвращает результат выполнения, а не ссылку на объект:<br /><a href="https://docs.microsoft.com/en-us/windows/win32/termserv/win32-terminalservice-changestartmode">https://docs.microsoft.com/en-us/window … estartmode</a><br />0 The request was accepted.<br />1 The request is not supported.<br />2 The user did not have the necessary access. <em>(у меня как раз возвращает 2 на все службы)</em><br />...</p>]]></content>
			<author>
				<name><![CDATA[andypetr]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40320</uri>
			</author>
			<updated>2022-05-11T08:56:35Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=153162#p153162</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBS: Изменение типа запуска службы и запуск службы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=153161#p153161" />
			<content type="html"><![CDATA[<p>Всем привет.<br />Имеется скрипт по запуску служб VMware.<br />Работают только строки svcX.StartService.<br />Строки svcX.ChangeStartMode(&quot;Manual&quot;).StartService выдают ошибки при запуске скрипта.<br />Не могу разобраться, как сделать так, чтобы сначала изменялся тип запуска служб, а уже потом происходил их запуск.</p><p>Сам скрипт:<br /></p><div class="codebox"><pre><code>
&#039; 
&#039; Script &quot;Change Start Mode and Run Services&quot;
&#039; 
Set wmi = GetObject(&quot;winmgmts://./root/cimv2&quot;)
&#039; 
&#039; VMware Mode and Start Services
&#039; 
Set svc = wmi.Get(&quot;Win32_Service.Name=&#039;VMAuthdService&#039;&quot;)
Set svc2 = wmi.Get(&quot;Win32_Service.Name=&#039;VMnetDHCP&#039;&quot;)
Set svc3 = wmi.Get(&quot;Win32_Service.Name=&#039;VMware NAT Service&#039;&quot;)
Set svc4 = wmi.Get(&quot;Win32_Service.Name=&#039;VMUSBArbService&#039;&quot;)
Set svc5 = wmi.Get(&quot;Win32_Service.Name=&#039;VMwareHostd&#039;&quot;)
svc.ChangeStartMode(&quot;Manual&quot;).StartService
svc2.ChangeStartMode(&quot;Manual&quot;).StartService
svc3.ChangeStartMode(&quot;Manual&quot;).StartService
svc4.ChangeStartMode(&quot;Automatic&quot;).StartService
svc5.ChangeStartMode(&quot;Disable&quot;).StartService
&#039; 
&#039; VMware Start Program
&#039; 
Set objShell = CreateObject(&quot;WScript.Shell&quot;)
&#039; Example (Program, Size, Parameters)
&#039; objShell.Run &quot;&quot;&quot;C:\Program Files (x86)\vlc.exe&quot;&quot; --fullscreen &quot;&quot;E:\eto test\Misfits.S01E05.mkv&quot;&quot;&quot;
objShell.Run &quot;&quot;&quot;C:\Program Files (x86)\VMware\VMware Workstation\vmware.exe&quot;&quot; &quot;&quot;&quot;&quot;&quot;
WScript.Quit
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[biffick]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40335</uri>
			</author>
			<updated>2022-05-11T07:40:58Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=153161#p153161</id>
		</entry>
</feed>
