通过批处理或类似方法在 Windows Embedded 标准上设置 Internet 时间服务器 [英] Setting internet time server on windows embedded standard through batch or similar

查看:34
本文介绍了通过批处理或类似方法在 Windows Embedded 标准上设置 Internet 时间服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行 windows 嵌入式标准的 PLC,我在其中进行了一些特定于我公司软件的安装和修改,作为我们安装过程的一部分(今天都是手动的).我现在正在自动化这个过程.

I have a PLC running windows embedded standard where I make some installations and modifications specific to my company's software as part of our installation process (which is all manual today). I'm now in the process of automating this procedure.

我想通过批处理文件或类似文件将日期和时间属性 -> 互联网时间服务器设置为 pool.ntp.org.命令

I want to set the Date and time properties->internet time server to pool.ntp.org through a batch file or similar. The command

w32tm

无法识别.我试过使用命令

is not recognized. I've tried using the command

净时间/setsntp:pool.ntp.org

返回

命令成功完成..

使用命令

净时间/querysntp

也返回

当前 SNTP 值为:pool.ntp.org命令成功完成.

但是,当我在日期和时间属性-> 互联网时间服务器下手动检查这些更改时,即使在重新启动后也不会反映这些更改.所以我想知道我正在使用的命令是否真的有效?有没有其他方法可以做到这一点?

But these changes are not reflected when I manually check them under Date and time properties->internet time server, not even after a restart. So I'm left wondering if the command I'm using is actually working? Is there another way to accomplish this?

以下 .bat 文件有效.仅注册表中的更改仅将服务器添加到列表中并使其成为默认值,但它没有启用同步.<代码>REG ADD HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionDateTimeServers/v "0"/t REG_SZ/d "pool.ntp.org"/fREG ADD HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionDateTimeServers/ve/d "0"/f网络时间/setsntp:pool.ntp.org

The following .bat file works. The changes in the registry alone only added the server to the list and made it default but it didn't enable syncing. REG ADD HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionDateTimeServers /v "0" /t REG_SZ /d "pool.ntp.org" /f REG ADD HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionDateTimeServers /ve /d "0" /f NET TIME /setsntp:pool.ntp.org

推荐答案

看一下regedit下面的路径;

Have a look in regedit under the following path;

HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionDateTimeServers

将您的服务器作为字符串值添加到该文件夹​​中 - 或者如果您愿意,您可以修改默认的 MS 提供的服务器.检查您的默认"服务器是什么(我的显示为 0),因为这是 Windows 将首先使用的服务器,并将其放在时间设置列表的顶部.

Add your server(s) into that folder as String Values - or you could modify the default MS provided ones if you prefer. Check what you 'default' server is (mine shows as 0) as that's the one Windows will use first, and put at the top of the list in the time settings.

如果您删除默认 MS 服务器并添加自己的服务器,请确保列表中至少有 2 个服务器,或者当您尝试 &访问时间与时钟内的日期"设置/互联网时间设置选项卡将崩溃并且永远不会显示列表.

If you delete the default MS servers and add your own ensure you have at least 2 servers in the list or when you try & access the 'Time & Date' setting / Internet time setting tab within the clock it will crash and never display the list.

如果您想配置任何特殊的 ntp 选项,请查看此路径;

If you want to configre any special ntp options then have a look at this path;

HKEY_LOCAL_MACHINESYSTEMCurrentControlSetservicesW32Time

重新启动Windows 时间"服务,您应该一切顺利.没有理由不能通过 .bat 或 power shell 编写脚本.

Restart the 'Windows Time' service and you should be good to go. There is no reason you couldn't script this either through a .bat or power shell.

这篇关于通过批处理或类似方法在 Windows Embedded 标准上设置 Internet 时间服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆