1

该脚本的目标是:

  1. 输入计算机名称并重新启动它
  2. 等它出现
  3. 发送新命令

如果没有第 2 步,这一切都很好。发生的情况是,第 2 步首先出现,然后机器重新启动(第 1 步)。我很困惑,这是代码:

nomePosto = InputBox("Nome do posto:", _
    "Correção Cert DSM")
intAnswer = _
MsgBox("Ao continuar o posto " & nomePosto & " vai reiniciar!",_ 
vbOkCancel, "ATENÇÃO")
if intAnswer = vbOk Then
CONST comm1 = " shutdown -r -f -t 1"
CONST comm2 = " md c:\teste"
set wshShell = WScript.CreateObject ("Wscript.Shell")
wshShell.run "psexec \\" & nomePosto & comm1
Set oIE = CreateObject("InternetExplorer.Application")
With oIE
    .navigate("about:blank")
    .Document.Title = "Aguarde ..." & string(100, chrb(160))
    .resizable=0
    .height=100
    .width=100
    .menubar=0
    .toolbar=0
    .statusBar=0
    .visible=1
End With
Do while oIE.Busy
wscript.sleep 500
Loop
oIE.document.body.innerHTML = "<div id=""countdown"" style=""font: 12pt sans-serif;text-align:center;""></div>"
for i=56 to 0 step -1
oIE.document.all.countdown.innerText= i
wscript.sleep 1000
next
wshShell.run "psexec \\" & nomePosto & comm2
oIE.quit
else
end if
Wscript.Quit
4

1 回答 1

0

Wscript.sleep 500 在第一个命令之后。

我已经尝试过了,但完全忽略了计算机启动需要更长的时间,这意味着一切都在相应地工作 duh

于 2013-01-09T11:51:07.313 回答