Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WSH Remote script takes forever to terminate

0 views
Skip to first unread message

Avijit

unread,
Sep 30, 2003, 1:52:02 PM9/30/03
to
Hi:

I am trying to execute a simple remote script (beenhere.wsf example). It
works fine but the local script that starts the remote script does not quit
immediately. It takes a long time (around 5 minutes) to get the command
prompt back. Inside a debugger also, I cannot break into the process or
anything. Any clue?

System configuration:
Local: WinXP Pro SP1 (WSH5.6)
Remote: Win2003/Win2k Server/WinXP Pro SP1 (no difference)

Here is the local script:
----------------------------
Dim Controller, RemoteScript
Set Controller = WScript.CreateObject("WSHController")
Set RemoteScript = Controller.CreateScript("c:\beenhere.wsf", "\\MYSERVER" )
WScript.ConnectObject RemoteScript, "RemoteScript_"
RemoteScript.Execute
Do While RemoteScript.Status <> 2
WScript.Sleep 100
Loop
WScript.DisconnectObject RemoteScript
msgbox "Finished..."
WScript.Quit

[ event handling code omitted - they just display messages]

The contents of "beenhere.wsf" is:
--------------------------------------
<package>
<job>
<script language="VBScript">
set fso = CreateObject("Scripting.FileSystemObject")
set fout = fso.CreateTextFile("c:\beenhere.txt", true)
fout.WriteLine Now
fout.Close
</script>
</job>
</package>

Thanks very much in advance for your help.

-- Avijit

Avijit

unread,
Sep 30, 2003, 3:42:54 PM9/30/03
to
I noticed the following:

1. It works fine with wscript.exe but the problem is when I run it using
CScript.exe
2. These scripts run ok in other XP systems. If I need to fix my WSH
installation how to do that?

My CScript.exe version: 5.6.8515

Thanks,

Avijit

"Avijit" <msdn-u...@wildpackets.com> wrote in message
news:O7gETu3h...@TK2MSFTNGP09.phx.gbl...

MSFT

unread,
Oct 1, 2003, 2:34:31 AM10/1/03
to
Hi Avijit,

If you didn't call "DisconnectObject", will it return right away?

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Avijit

unread,
Oct 1, 2003, 7:45:02 PM10/1/03
to
Hi Luke:

Not calling "DisconnectObject" has the same effect i.e., it still waits for
about 5 minutes.

Thanks,

Avijit

"MSFT" <luke...@online.microsoft.com> wrote in message
news:QgaADZ%23hDH...@cpmsftngxa06.phx.gbl...

MSFT

unread,
Oct 2, 2003, 5:32:38 AM10/2/03
to
The primary difference between the CScript and WScript environments is that
the CScript environment directs display information to the command window,
which has a side effect of letting a script run to completion without
pausing for each message sent to the UI. I suspect the Wscript also delay
for 5 minutes and we havn't found that. And this may be a network
configration issue on the perticualr Windows XP computer. You may test to
run script on local computer to see if this make difference. and check if
it delay on following code:

Do While RemoteScript.Status <> 2
WScript.Sleep 100
Loop

Luke

Avijit

unread,
Oct 6, 2003, 1:11:14 PM10/6/03
to
Thanks Luke for your help.

Making the change as you suggested also didn't work. I also tested with
JScript and found the same behavior. Here is the JScript code I used:

var oController = WScript.CreateObject("WSHController");
var oProcess = oController.CreateScript("c:\\remote-test\\beenhere.wsf",
"ac-test-winxp");
oProcess.Execute();
do {
WScript.Sleep(100);
} while ( oProcess.Status != 2 );
WScript.Echo("Done");

The "beenhere.wsf" remains the same VBScript code.

Also, I am not sure what you meant by "You may test to run script on local
computer". If you meant running "beenhere.wsf" locally, then the answer is
yes - I tired it. beenhere.wsf exits immediately after creating the file
"C:\beenhere.txt" as expected.

-- Avijit

"MSFT" <luke...@online.microsoft.com> wrote in message

news:2H1ElgMi...@cpmsftngxa06.phx.gbl...

Mike Dutra

unread,
Oct 6, 2003, 2:12:22 PM10/6/03
to
If you add the following to the calling script do both of them get called?

Sub Remote_Start
Wscript.Echo "Started"
End Sub

Sub Remote_End
Wscript.Echo "Finished"
End Sub

Basically I want to see if the remote script finishes immediately or after
5 minutes.

Mike Dutra
Microsoft Developer Support WSH/WMI/Cluster Dev

Disclaimer: This posting is provided "AS IS" with no warranties, and
confers no rights. You assume all risk for your use.

Avijit

unread,
Oct 7, 2003, 12:26:09 AM10/7/03
to
Both of the event handlers get called immediately indicating that the script
finishes immediately but then it takes about 5 minutes before I get the
command prompt back. As I noted earlier, if I am inside a debugger, I can't
break the process either.

I also tried to attach the Visual Studio (7.01) debugger with the
cscript.exe process and it attaches ok. However, when I try to break, I get
an error message: "Unable to break execution. The process does not contain
any programs."

Thanks,

Avijit

"Mike Dutra" <mdu...@online.microsoft.com> wrote in message
news:bnXviVDj...@cpmsftngxa06.phx.gbl...

Mike Dutra

unread,
Oct 7, 2003, 7:57:12 PM10/7/03
to
I assume you have been able to step through the at least some of the code
of the local script? Or does it give you the error immediately? If you are
able to step through some of the code, what is the last line that executes
before the hang occurs?

Also, this only occurs on one XP machine? You could try reinstalling WSH on
that machine from the http://msdn.microsot.com/scripting site.

Basically it sounds like WSH is waiting on something to finish. It may be
that something is timing out or it may actually be finishing. The only way
I know of to determine what that something is would be to get a user dump
of the cscript process during the hang. From that we can find out at least
what type of item WSH is waiting on (thread, port, process, etc). You may
want to call in and create a case as I can think of nothing off hand that
would cause this. In all other issues like this there was an object created
that was the culprit. In this case there are not really any objects other
than the WshRemote object. In all cases I needed a process dump to
determine the hang.

Avijit

unread,
Oct 7, 2003, 9:05:20 PM10/7/03
to
I goes through every statement nicely. Then it disappears! (i.e., no call
stack in the debugger, can't even break).

I can send you a user dump. Could you please let me know how to do that?

Thanks,

Avijit

"Mike Dutra" <mdu...@online.microsoft.com> wrote in message

news:37QBO7Sj...@cpmsftngxa06.phx.gbl...

Mike Dutra

unread,
Oct 8, 2003, 1:53:00 PM10/8/03
to
Go to the following website and download the debugging tools:
http://www.microsoft.com/whdc/ddk/debugging/default.mspx

Once you download and install then open windbg.
Goto File and Attach to a process and select cscript.exe (or wscript.exe,
which ever is loaded)

Once broken in you need to go to the command window and type in the
following command:

dump /mfh c:\script.dmp

I am not sure how big it will be so you may need to zip it up.

Avijit

unread,
Oct 8, 2003, 9:05:32 PM10/8/03
to
I have downloaded the Windbg and them attepmted to attach with the
CScript.exe. It is unable to attach!

I opened the Command window and the status bar says "Debugee not connected".
Therefore I am unable to get the dump.

Please let me know what would be the next step.

Thanks,

Avijit

"Mike Dutra" <mdu...@online.microsoft.com> wrote in message

news:uWh1FUcj...@cpmsftngxa06.phx.gbl...

Mike Dutra

unread,
Oct 9, 2003, 2:33:53 PM10/9/03
to
Make sure you are not in a terminal session. It will only work from the
console. I don't know if permissions has anything to do with it but I would
try it as an admin.

Avijit

unread,
Oct 10, 2003, 11:40:18 AM10/10/03
to
I am logged in interactively and have full admin rights on this system.

Thanks,

Avijit

"Mike Dutra" <mdu...@online.microsoft.com> wrote in message

news:B9XsQPpj...@cpmsftngxa06.phx.gbl...

Mike Dutra

unread,
Oct 13, 2003, 9:28:27 AM10/13/03
to
When it fails to attach can you see it in the process list if you try to
attach again? Can you attach to any other process? Try running notepad and
attaching to it. Be aware that when you detach the exe will terminate.

Avijit

unread,
Oct 13, 2003, 2:04:35 PM10/13/03
to
Yes. The process is still in the process list (after multiple attempts to
attach failed).
I can attach to other processes and used the notepad and it attached fine.

Thanks,

Avijit

"Mike Dutra" <mdu...@online.microsoft.com> wrote in message

news:973bn3Yk...@cpmsftngxa06.phx.gbl...

Mike Dutra

unread,
Oct 14, 2003, 2:30:27 PM10/14/03
to
When you try to attach, check the non-invasive checkbox. It may be that you
have no available threads that are not hung to attach to.
0 new messages