BUG: WshRemote

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Note: I've already reported this problem the WSH dev team.

I can repro the problem with at least 2 relatively recent 5.6.0.build
versions (8825 and 8827) of wscript.exe and that it works on at least 2
older 5.6.0.build versions (6626 and 8515).

If you have the time and have wscript.exe builds other than the 2 that work
and the 2 that don't that I have found, I would appreciate the feedback on
theworks/fails status of those other builds. It will come in handy to
isolate the first build that introduced the bug.

Here's a description of the problem with repro scripts. Note that the
WshRemote instance does not need to be created on a different server, just
out of process on the same machine as the controller script.

====================================================

We have a production scheduled job using a WshController/WshRemote technique
that has been working as expected against W2003 remote servers for quite
some time that began failing when those servers were recently upgraded to
w2003 sp1.

Somewhere between wscript.exe 5.6.0.8515 (works) and 5.6.0.8825 (fails), a
WshRemote bug was introduced.

If the remotely executed script calls wscript.quit (regardless of exit
code), WshRemote fails with...

Error -2147467259 (hex 80004005) Line: 0, Char: 0
Description: Execution of the Windows Script Host failed.

If you replace the Wscript.quit call wirh...

Err.raise &h999,"my error source","my error description"

....then the captured error becomes...

Error -2146825831 (hex 800A0999) Line: 0, Char: 0
Description: Execution of the Windows Script Host failed.

Note that only the error number/hex is correct.

This fails if the WshRemote instance is...

Wscript.exe 5.6.0.8825 (w2k pro sp4)
Wscript.exe 5.6.0.8825 (xp pro sp2)
Wscript.exe 5.6.0.8827 (w2003 sp1)

....but works if the WshRemote instance is...

Wscript.exe 5.6.0.6626 (w2k server sp4)
Wscript.exe 5.6.0.8515 (w2003 wo any sp)

There may be other builds that work/fail, but these 4 are the ones I could
easily test.

To repro: Save controller.vbs and remote.vbs in the same folder.

'-----controller.vbs-----

Set shell = createobject("wscript.shell")
shell.currentdirectory = wscript.scriptfullname & "\.."

Dim Controller, RemoteScript
Set Controller = WScript.CreateObject("WSHController")
Set RemoteScript = Controller.CreateScript("remote.vbs")
WScript.ConnectObject RemoteScript, "remote_"
RemoteScript.Execute

Do While RemoteScript.Status <> 2
WScript.Sleep 100
Loop
msgbox "normal exit"

WScript.DisconnectObject RemoteScript

Sub remote_Error
Dim theError
Set theError = RemoteScript.Error
WScript.Echo "Error " & theError.Number _
& " (hex " & Hex(theError.Number) _
& ") Line: " & theError.Line _
& ", Char: " & theError.Character & vbCrLf _
& "Description: " & theError.Description
msgbox "remote error"
WScript.Quit 99
End Sub

'-----remote.vbs-----

set shell = createobject("wscript.shell")
shell.logevent 4,Now()
'Err.raise &h999,"my error source","my error description"
wscript.quit 0


--
Michael Harris
Microsoft.MVP.Scripting


.