<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: изменения типа запуска сервиса через WMI]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=7982&amp;type=atom" />
	<updated>2015-11-05T13:59:08Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=7982</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: изменения типа запуска сервиса через WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98685#p98685" />
			<content type="html"><![CDATA[<p>Можно вписать:<br /></p><div class="codebox"><pre><code>ComObjError(false)</code></pre></div><p>А ошибку отлавливать с помощью A_LastError.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2015-11-05T13:59:08Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98685#p98685</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: изменения типа запуска сервиса через WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98679#p98679" />
			<content type="html"><![CDATA[<p>Иногда антивирус блокирует скомпилированный файл и программа крашится с сообщением об ошибке в строке ComObjGet что-то вроде &quot;сервис недоступен&quot;. Можно поставить какую-то проверку для таких случаев, чтобы вместо краха программы выдавалось стандартное сообщение?</p>]]></content>
			<author>
				<name><![CDATA[Kurskador]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33207</uri>
			</author>
			<updated>2015-11-05T09:58:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98679#p98679</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: изменения типа запуска сервиса через WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=68568#p68568" />
			<content type="html"><![CDATA[<p>Идеальный вариант. Спасибо <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[chippp]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=28524</uri>
			</author>
			<updated>2013-01-16T13:25:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=68568#p68568</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: изменения типа запуска сервиса через WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=68559#p68559" />
			<content type="html"><![CDATA[<p>Тогда уж<br /></p><div class="codebox"><pre><code>SetServiceStartMode(serviceDisplayName, startMode) {
    WMI := ComObjGet(&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot; . A_ComputerName . &quot;\root\cimv2&quot;)
    ServiceList := WMI.ExecQuery(&quot;SELECT * FROM Win32_Service WHERE DisplayName=&#039;&quot; . serviceDisplayName . &quot;&#039;&quot;)
    None := ComObjMissing()

    for Service in ServiceList
        return Service.Change(None, None, None, None, startMode)
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2013-01-16T11:23:22Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=68559#p68559</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: изменения типа запуска сервиса через WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=68553#p68553" />
			<content type="html"><![CDATA[<p>Всем устраивает <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> Просто дело привычки <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> Ваш вариант тоже сохранил , вдруг пригодится <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br />Да и метод <strong>Change</strong> позволяет внести больше изменений при незначительном изменении кода функции. Хотя в данном случае это не важно.</p>]]></content>
			<author>
				<name><![CDATA[chippp]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=28524</uri>
			</author>
			<updated>2013-01-16T11:02:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=68553#p68553</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: изменения типа запуска сервиса через WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=68549#p68549" />
			<content type="html"><![CDATA[<p>А чем вас не устраивает метод ChangeStartMode использовавшийся в примере сообщения #2?<br />Интересуюсь в образовательных целях.</p>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2013-01-16T10:55:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=68549#p68549</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: изменения типа запуска сервиса через WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=68546#p68546" />
			<content type="html"><![CDATA[<p>Функция называется <strong>GetModuleExeName</strong> потому что базово была одна функция, а содержимое изменил. Ибо все содержимое в тестовом скрипте с кучей всего всего всего <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p><p>Огромное спасибо за помощь <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> вот такой вариант заработал:</p><div class="codebox"><pre><code>ServName:=&quot;TeamViewer 7&quot;
msgbox % SetStopServiceMod(ServName)

SetStopServiceMod(sname) {
for service in ComObjGet(&quot;winmgmts:&quot;).ExecQuery(&quot;select * from win32_service WHERE DisplayName=&#039;&quot; . sname . &quot;&#039;&quot;)
errorreturncode:=service.Change(ComObjMissing(), ComObjMissing(), ComObjMissing(), ComObjMissing(),&quot;Disabled&quot;)
        
return errorreturncode

}
</code></pre></div><p>P.S. Здравый смысл include</p>]]></content>
			<author>
				<name><![CDATA[chippp]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=28524</uri>
			</author>
			<updated>2013-01-16T10:53:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=68546#p68546</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: изменения типа запуска сервиса через WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=68544#p68544" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>; Требует права администратора.
SetServiceStartMode(serviceDisplayName, startMode) {
    WMI := ComObjGet(&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot; . A_ComputerName . &quot;\root\cimv2&quot;)
    ServiceList := WMI.ExecQuery(&quot;SELECT * FROM Win32_Service WHERE DisplayName=&#039;&quot; . serviceDisplayName . &quot;&#039;&quot;)

    for Service in ServiceList
        return Service.ChangeStartMode(startMode)
}

MsgBox % SetServiceStartMode(&quot;TeamViewer 7&quot;, &quot;Disabled&quot;)
</code></pre></div><p>Почему функция названа <strong>GetModuleExeName</strong>? Почему обязательный параметр p_id не используется?<br />Здравый смысл никто не отменял <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p><p>Пустые параметры в методы COM объектов в ahk передаются с помощью <strong>ComObjMissing()</strong>.</p>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2013-01-16T10:29:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=68544#p68544</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: изменения типа запуска сервиса через WMI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=68538#p68538" />
			<content type="html"><![CDATA[<p>Собственно проблема: при выполнении кода ошибка <strong>(19) : ==&gt; Blank parameter Specifically: .Change(, , , ,&quot;Disabled&quot;) </strong></p><div class="codebox"><pre><code>msgbox % GetModuleExeName(PID)

GetModuleExeName(p_id) {
        for service in ComObjGet(&quot;winmgmts:&quot;).ExecQuery(&quot;select * from win32_service WHERE DisplayName=&#039;TeamViewer 7&#039;&quot;)
        errorreturncode:=service.Change(, , , ,&quot;Disabled&quot;)
        
        return errorreturncode

}</code></pre></div><p>Какие параметры необходимо передать что бы небыло ошибки, т.к. в оригинале на VB передаются пустые параметры:</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 colServiceList = objWMIService.ExecQuery _
    (&quot;Select * from Win32_Service where StartMode = &#039;Manual&#039;&quot;)
For Each objService in colServiceList
    errReturnCode = objService.Change( , , , , &quot;Disabled&quot;)
    WScript.Echo &quot;Changed manual service to disabled: &quot; &amp; objService.Name   
Next</code></pre></div><p><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa394602(v=vs.85).aspx">http://msdn.microsoft.com/en-us/library … s.85).aspx</a></p>]]></content>
			<author>
				<name><![CDATA[chippp]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=28524</uri>
			</author>
			<updated>2013-01-16T09:30:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=68538#p68538</id>
		</entry>
</feed>
