wmi解决方案
这个解决方案从代码方面看是一个很容易执行的方法,可下载代码包是:rebootnt_wmi.zip
首先要设置对microsoft wmi 脚本库wbemdisp.tlb的引用,这可以从vb代码中调用(本例中就是这样),或者从脚本语言中调用,比如:
private sub cmdlocalreboot_click()
dim p_objset as swbemobjectset
dim p_objswbemobj as object
set p_objset = getobject("winmgmts:{(shutdown)}//./root/cimv2"). _
execquery("select * from win32_operatingsystem where primary=true")
for each p_objswbemobj in p_objset
p_objswbemobj.reboot
next p_objswbemobj
end sub
private sub cmdremotereboot_click()
dim p_objset as swbemobjectset
dim p_objswbemobj as object
dim p_strserver as string
p_strserver = me.text1.text
set p_objset = getobject("winmgmts:{(debug,remoteshutdown)}//" _
& p_strserver & "/root/cimv2"). _
execquery("select * from win32_operatingsystem where primary=true")
for each p_objswbemobj in p_objset
p_objswbemobj.reboot
next p_objswbemobj
end sub
这个相当简易的方法的缺点是:wmi 只在win2k操作系统上有效。对于nt 4.0或 win9x,就必须下载并安装wmi ,详细资料请参见msdn。并且,这个方法对win9x的重新启动不起作用。
结 语
ok,如果你需要在网络上重新启动一个或多个计算机,上面已经向你展示了一些不同的方法。请记住,如果你强制执行重新启动,那么无论选择哪种方法,任何打开的程序都将没有机会来保存那些未经存储的数据。
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器