1

the goal of this script is:

  1. input computer name and restart it
  2. wait for it to come up
  3. sends new command

This all works great without step 2. What's happening is that, step two comes first and then the machine is restarted (step 1). I'm confused, here's the code:

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。

私はこれを試してみましたが、コンピューターの起動に時間がかかっていることを完全に無視しました。つまり、すべてが適切に機能していたことを意味します

于 2013-01-09T11:51:07.313 に答える