如何确定 Windows 何时完成重新启动?
我正在使用 Windows Update API 来更新一堆虚拟机。 Windows 更新不可避免地会导致重新启动。 任何人都可以想出一种方法,让我可以从远程服务器判断 Windows 盒子是否确实完成了重新启动? 所有想法或想法将不胜感激。
编辑: 由于虚拟机位于 Lab Manager 中并使用隔离配置,因此 WMI 将无法工作,尽管我考虑过使用虚拟机在备份时发送信号。 没有办法可靠地知道要通知谁,因为等待机器的应用程序可能位于任意数量的机器上,因此这似乎不合理。 然而时间并不是必需的(尽管我知道当 Service Pack 出现时这有时会困扰我)我已经在 PING 方面取得了很好的成功,然后到目前为止等待 5 分钟,所以我现在将使用它。 如果我遇到异常,我将尝试实现虚拟机在恢复时通知世界。 谢谢大家。
I am using the Windows Update API to update a bunch of VM's. With Windows Update comes the inevitable reboots. Can anyone think of a way that I could tell from a remote server if the windows box has indeed finished its reboot? All ideas or thoughts would appreciated.
EDIT:
Because the VM's are in Lab Manager and using a fenced configuration, WMI will not work, and although I thought about using the VM to send a signal when it was back up. There would have been no way to reliably know who to notify as the app waiting for the machine could be on any number of machines so it just didn't seem reasonable. However time is not essential (and even though I know this will bite me sometime when a Service Pack comes down) I have had good success with the PING and then wait 5 minutes so far, so I am going to use that for now. If I run into exceptions I will then try to implement the VM notfiying the world when it comes back up. Thanks to all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
只需等待它响应 ping 即可。
根据您的评论:
1 - 使用此脚本
2 - 如果您收到任何该脚本出现错误,按照这些说明操作。
Just wait for it to respond to a ping.
In light of your comments:
1 - Use this script
2 - If you get any errors with that script, follow these instructions.
在事件日志中检查此事件:
Check for this event in the event log:
这个问题的更一般版本是 我怎么知道系统是否已开机?
A more general version of this question is How do I know if a system has powered on?
现实情况是您无法知道它何时完成启动。 启动过程是相当异步的,因此无论您使用什么标准来确定它已完成,“启动”都可能在其他事情完成之前发生。
我的建议是确定你真正想知道什么。 您具体在等待什么? 找到一种方法来确定是否发生了这种情况,而不必担心“启动”。
如果您只需要知道计算机已备份,但可能尚未完成所有启动后加载,请在启动序列中添加一些内容或向您的代码发出信号的服务。 当出现此信号时,请采取您需要采取的任何行动。
The reality is that you can't know when it is done booting. The boot process is pretty asynchronous and so whatever criteria you use to determine that it is done "booting" could happen before something else completes.
What I would recommend is determine what you actually want to know. What specifically is it you are waiting for? Find a way to determine whether this has taken place and forget worrying about "booting".
If you just need to know that the machine is back up but maybe hasn't completed all of the post-boot loading, put something in the startup sequence or a service that signals your code. When this signal takes place, take whatever action you need to.
您可以在计算机上安装启动程序或服务,以便在每次重新启动时发送电子邮件或某种类型的基于网络的发布。
You could install a startup program or service on the machine to send an email or some type of network based posting everytime it restarts.
Windows 在需要再次重新启动之前仅稍微重新启动:-)
如果您专门希望查询 VM 的状态,那么您应该查看这些处理 Virtual Server 2005 API 的链接:
IVMVirtualMachine Interface。
http://msdn.microsoft.com/en- us/library/aa368465(VS.85).aspx
...有一个名为 State 的属性...
IMVVirtualMachine::State 属性
http://msdn.microsoft.com/en-us/library/aa368637(VS.85).aspx
...它将从 VMVMState 枚举返回一个值...
http ://msdn.microsoft.com/en-us/library/aa368922(VS.85).aspx
在更一般的层面上,您可能应该定义您想要启动和运行多少 Windows。 您是否认为网络堆栈已准备好“重新启动”,或者您是否需要 IIS/SQL 或其他一些应用程序级别的服务?
我可能会编写一个应用程序来检查服务器的“心跳” - 该应用程序很可能与调用 Windows 更新内容的应用程序相同。 然后,您会得到一个很好的“控制台”,向您显示服务器的状态。 心跳应用程序可以 ping 服务器、访问静态 html 页面、访问远程事件日志、使用 WMI 或任何您定义的足以认为服务器已重新启动的内容。
Windows is done rebooting only slightly before it'll need rebooting again :-)
If you're specifically looking to query the status of VMs then you should check out these links which deal with the API for Virtual Server 2005:
The IVMVirtualMachine Interface...
http://msdn.microsoft.com/en-us/library/aa368465(VS.85).aspx
... has a property called State...
IVMVirtualMachine::State Property
http://msdn.microsoft.com/en-us/library/aa368637(VS.85).aspx
... which will return a value from the VMVMState Enumeration...
http://msdn.microsoft.com/en-us/library/aa368922(VS.85).aspx
At a more general level, you should probably define how much of Windows you want up and running. Do you consider network stack ready to be "rebooted" or do you need IIS/SQL or some other application level service up?
I'd probably write an app that checks the "heart-beat" of your servers - that app could well be the same one that's invoking the Windows Update stuff. You'd then get yourself a nice "console" showing you the status of your servers. The heart-beat app could ping a server, hit a static html page, hit the remote event log, use WMI or whatever you define as enough to consider your server rebooted.