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

WshScriptExec.Terminate returns error

84 views
Skip to first unread message

Gary

unread,
Dec 16, 2005, 2:08:10 PM12/16/05
to
I have a simple script, something like:
Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec("myprogram")
Wscript.Sleep 10000
objExec.Terminate

I run this as a Scheduled task. If I stay logged on, it runs without error.
If I log off, the objExec.Terminate statement returns
c:\Scripts\Myscript.vbs(33, 1) (null): Invalid window handle.

I know the program runs, and exits when I execute objExec.Terminate. What is
the error telling me?


Thank you.

Gary


tlavedas@hotmail_DOT_com

unread,
Dec 17, 2005, 4:36:57 PM12/17/05
to
Scheduled tasks do not have access to the interactive console that the
Exec method requires. There used to be a way to enable this through
the old NT 'at' command - I just checked the help for Win2k and it's
still available. So, I guess that might be a way to schedule the job.

Or, if you don't need the access to the StdIn/StdOut functions, etc.
that Exec provides, you could just switch to the Run method instead.

Tom Lavedas
============
http://my.fcc.net/~tglbatch/wshindex.html (new URL - old content)

Gary

unread,
Dec 19, 2005, 3:15:45 PM12/19/05
to
The reason I used the Exec method is that I need to Terminate the task after
it has run for a period of time. That didn't seem so easy to do if I used
the Run method. I believe I will need to control the task scheduling through
scripting, also, so will have to use the AT form of scheduling.

Gary

"tlavedas@hotmail_DOT_com" <tlav...@hotmail.com> wrote in message
news:1134855417....@g43g2000cwa.googlegroups.com...

0 new messages