找回密码
 加入
搜索
查看: 1766|回复: 0

[AU3基础] 請協助將vbs轉成au3

[复制链接]
发表于 2010-9-15 08:02:25 | 显示全部楼层 |阅读模式
reboot.vbs
----------------------------------------------------------
Option Explicit

Dim strComputer
Dim strUser
Dim strPassword
Dim oWshShell
Dim objSWbemLocator
Dim objSWbemServices
Dim colOperatingSystems
Dim objOperatingSystem

Set oWshShell = CreateObject("Wscript.Shell")

strComputer = UCase(InputBox("Please enter the Computer Name: "))
strUser = InputBox("Please enter the Administrator Name: ")
strPassword = InputBox("Please enter the administrator password: ")
On Error Resume Next
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = objSWbemLocator.ConnectServer _
    (strComputer, "root\cimv2", strUser, strPassword)

If Err.Number <> 0 Then
        oWshShell.Popup "WMI Connection was not successful. "  & Chr(13) &_
    Err.Description, 10, Err.Source & " on " & strComputer, 48
Else
        Set colOperatingSystems = objSWbemServices.ExecQuery _
        ("Select * from Win32_OperatingSystem")
        For Each objOperatingSystem in colOperatingSystems
        ObjOperatingSystem.Reboot()
        Next

If Err.Number <> 0 Then
        oWshShell.Popup "Reboot operation was not successful. " & Chr(13) _
   & Err.Description, 10, Err.Source & " on " & strComputer, 48
        Else
        oWshShell.Popup strComputer  & " is restarting.", 10, "Successful.", 64
End If
End If
-----------------------------------------------------------------

如上所示
我試著改了很久,但是還是改不出來
我的盲點是,vbs中的
On Error Resume Next
If Err.Number
Err.Description

感謝
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-13 17:14 , Processed in 0.102381 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表