<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Включение синхронизации с сервером времени.]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=12755&amp;type=atom" />
	<updated>2017-06-18T20:24:45Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=12755</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Включение синхронизации с сервером времени.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=116752#p116752" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>А чтобы сработало без ошибок, можно проверять оба варианта:</p></blockquote></div><p>Вот этот вариант очень хорошо работает, протестировал на windows 7/10 x32 системах. Спасибо за помощь!</p>]]></content>
			<author>
				<name><![CDATA[powercat]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=37884</uri>
			</author>
			<updated>2017-06-18T20:24:45Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=116752#p116752</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Включение синхронизации с сервером времени.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=116718#p116718" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>lexikos пишет:</cite><blockquote><p>I would suggest testing the following:</p><p>&nbsp; &nbsp; Run directly from a 32-bit command prompt. That is, launch C:\Windows\SysWow64\cmd.exe and paste your command line there.<br />&nbsp; &nbsp; Run the 64-bit command processor from AutoHotkey 32-bit. That is, RunWait C:\Windows\SysNative\cmd.exe ....<br />&nbsp; &nbsp; Run w32tm 32-bit directly (see below). w32tm is an executable; cmd.exe is not needed except to force the output to remain on screen (but you can get around that).<br />&nbsp; &nbsp; Run w32tm 64-bit directly. That is, RunWait C:\Windows\SysNative\w32tm.exe ....</p></blockquote></div><p>Имхо, сюда незачем примешивать ещё и битность cmd.exe, она ведь в реальности не используется. Протестировать можно так:<br /></p><div class="codebox"><pre><code>cmd = w32tm /config /update /manualpeerlist:&quot;0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org&quot; /syncfromflags:MANUAL /reliable:yes
MsgBox, % StdOut(cmd, &quot;cp866&quot;)

StdOut(sCmd, encoding)
{
   static STARTF_USESTDHANDLES := 0x100, CREATE_NO_WINDOW := 0x08000000
   
   DllCall(&quot;CreatePipe&quot;, PtrP, hStdInRd, PtrP, hStdInWr, UInt, 0, UInt, 0)
   DllCall(&quot;CreatePipe&quot;, PtrP, hStdOutRd, PtrP, hStdOutWr, UInt, 0, UInt, 0)
   DllCall(&quot;SetHandleInformation&quot;, Ptr, hStdInRd, UInt, 1, UInt, 1)
   DllCall(&quot;SetHandleInformation&quot;, Ptr, hStdOutWr, UInt, 1, UInt, 1)
   
   VarSetCapacity(pi, A_PtrSize*2 + 8, 0)
   NumPut( VarSetCapacity(      si, A_PtrSize*4 + 4*8 + A_PtrSize*5, 0), si )
   NumPut(STARTF_USESTDHANDLES, si, A_PtrSize*4 + 4*7)
   NumPut(hStdInRd            , si, A_PtrSize*4 + 4*8 + A_PtrSize*2)
   NumPut(hStdOutWr           , si, A_PtrSize*4 + 4*8 + A_PtrSize*3)
   NumPut(hStdOutWr           , si, A_PtrSize*4 + 4*8 + A_PtrSize*4)

   DllCall(&quot;CreateProcess&quot;, UInt, 0, Ptr, &amp;sCmd, UInt, 0, UInt, 0, Int, True, UInt, CREATE_NO_WINDOW, UInt, 0, UInt, 0, Ptr, &amp;si, Ptr, &amp;pi)
   
   for k, v in [NumGet(pi, 0), NumGet(pi, A_PtrSize), hStdOutWr, hStdInRd, hStdInWr]
      DllCall(&quot;CloseHandle&quot;, Ptr, v)

   VarSetCapacity(sTemp, 4095)
   while DllCall(&quot;ReadFile&quot;, UInt, hStdOutRd, Ptr, &amp;sTemp, UInt, 4095, UIntP, nSize, UInt, 0)
      sOutput .= StrGet(&amp;sTemp, nSize, encoding)
   DllCall(&quot;CloseHandle&quot;, Ptr, hStdOutRd)
   Return sOutput
}</code></pre></div><p>А чтобы сработало без ошибок, можно проверять оба варианта:<br /></p><div class="codebox"><pre><code>ComObjError(false)
w32time := ComObjGet(&quot;winmgmts:&quot;).Get(&quot;Win32_Service.Name=&#039;w32time&#039;&quot;)
if A_LastError
{
   RunWait w32tm /register,, Hide
   msgbox нужен рестарт компьютера
   ExitApp
}
state := w32time.state
if (state = &quot;stopped&quot;)
{
   StartMode := w32time.StartMode
   if (StartMode = &quot;Disabled&quot;)
      w32time.ChangeStartMode(&quot;Automatic&quot;)
   w32time.StartService
}
for k, quotes in [&quot;&quot;&quot;&quot;, &quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;]  {
   RunWait, % &quot;w32tm /config /update /manualpeerlist:&quot;
             . quotes . &quot;0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org&quot; . quotes
             . &quot; /syncfromflags:MANUAL /reliable:yes&quot;,, Hide
;  MsgBox, % ErrorLevel
} until !ErrorLevel
RunWait w32tm /resync /force,, Hide</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-06-17T14:42:27Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=116718#p116718</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Включение синхронизации с сервером времени.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=116706#p116706" />
			<content type="html"><![CDATA[<p>Отписал. Посмотрим, что ответят.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-06-17T05:49:14Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=116706#p116706</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Включение синхронизации с сервером времени.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=116705#p116705" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>Но если же запускать через ahk32 бит, то нужно эти кавычки утраивать.</p></blockquote></div><p>Действительно, похоже на баг. Попробуй спросить на форуме, интересно, в чём проблема.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-06-17T05:28:24Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=116705#p116705</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Включение синхронизации с сервером времени.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=116704#p116704" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>У меня первые два варианта выдают одинаковую ошибку</p></blockquote></div><p>Похоже, лишний пробел вставлял.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-06-17T05:17:58Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=116704#p116704</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Включение синхронизации с сервером времени.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=116703#p116703" />
			<content type="html"><![CDATA[<p>Ага, подтверждаю.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-06-17T05:15:09Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=116703#p116703</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Включение синхронизации с сервером времени.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=116701#p116701" />
			<content type="html"><![CDATA[<p>Ну так я о чём.<br />С одним сервером кавычки не нужны.<br />Если же список серверов, то нужны кавычки (в 26 посте я привёл ссылку).<br />И самое интересное, что если запускать скрипт через ahk64 бит, то указываешь одинарные кавычки, что логично, т ак как это строка.<br />Но если же запускать через ahk32 бит, то нужно эти кавычки утраивать.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-06-17T05:10:56Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=116701#p116701</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Включение синхронизации с сервером времени.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=116700#p116700" />
			<content type="html"><![CDATA[<p>Выяснил, что если указывать один сервер, то работает с любым. Значит, просто синтаксис неверный.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-06-17T05:08:03Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=116700#p116700</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Включение синхронизации с сервером времени.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=116699#p116699" />
			<content type="html"><![CDATA[<p>А, нет, неправильно просто написал, перед сервером пробел поставил. С моим работает.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-06-17T05:05:35Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=116699#p116699</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Включение синхронизации с сервером времени.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=116698#p116698" />
			<content type="html"><![CDATA[<p>У меня работает так и на 32-бит и на 64:<br /></p><div class="codebox"><pre><code>runwait, cmd.exe /k w32tm /config /update /manualpeerlist:time-a.nist.gov /syncfromflags:MANUAL /reliable:yes</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-06-17T05:03:42Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=116698#p116698</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Включение синхронизации с сервером времени.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=116696#p116696" />
			<content type="html"><![CDATA[<p>А сейчас вот у меня даже с моим сервером не работает:<br /></p><div class="quotebox"><blockquote><p>Следующие аргументы были непредвиденными:<br /> time-a.nist.gov</p></blockquote></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-06-17T05:00:32Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=116696#p116696</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Включение синхронизации с сервером времени.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=116695#p116695" />
			<content type="html"><![CDATA[<p>Работает, потому что с одним сервером кавычки вообще не нужны:<br /></p><div class="quotebox"><blockquote><p>manualpeerlist:&lt;peers&gt;—Sets the manual peer list to &lt;peers&gt;, which is a space-delimited list of Domain Name System (DNS) and/or IP addresses. When you are specifying multiple peers, this option must be enclosed in quotation marks (“).</p></blockquote></div><p><a href="https://technet.microsoft.com/en-us/library/ff799054(v=ws.11).aspx">https://technet.microsoft.com/en-us/lib … s.11).aspx</a></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-06-17T04:55:20Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=116695#p116695</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Включение синхронизации с сервером времени.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=116694#p116694" />
			<content type="html"><![CDATA[<p>У меня с моим сервером на 32-битном работает так же.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-06-17T04:50:18Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=116694#p116694</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Включение синхронизации с сервером времени.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=116693#p116693" />
			<content type="html"><![CDATA[<p>Интересно.<br />На 64-битном ahk надо запускать с одинарными кавычками:<br /></p><div class="codebox"><pre><code>runwait, cmd.exe /k w32tm /config /update /manualpeerlist:&quot;0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org&quot; /syncfromflags:MANUAL /reliable:yes</code></pre></div><p>А на 32-битном с тройными:<br /></p><div class="codebox"><pre><code>runwait, cmd.exe /k w32tm /config /update /manualpeerlist:&quot;&quot;&quot;0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org&quot;&quot;&quot; /syncfromflags:MANUAL /reliable:yes</code></pre></div><p>Баг что ли?</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-06-17T04:39:09Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=116693#p116693</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Включение синхронизации с сервером времени.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=116692#p116692" />
			<content type="html"><![CDATA[<p>У меня первые два варианта выдают одинаковую ошибку:</p><div class="quotebox"><blockquote><p>Следующие аргументы были непредвиденными:</p><p> &quot;0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org&quot;</p></blockquote></div><p>Третий тоже не работает:</p><div class="quotebox"><blockquote><p>Неизвестная команда /config /update /manualpeerlist:&quot;0.pool.ntp.org.</p></blockquote></div><p>Зато с сервером, прописанным у меня, всё в порядке:<br /></p><div class="codebox"><pre><code>runwait, cmd.exe /k w32tm /config /update /manualpeerlist:&quot;time-a.nist.gov&quot; /syncfromflags:MANUAL /reliable:yes</code></pre></div><div class="quotebox"><blockquote><p>Команда выполнена успешно.</p></blockquote></div><p>С одинарными кавычками.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-06-17T04:15:35Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=116692#p116692</id>
		</entry>
</feed>
