Detecting Terminal Srvices Console

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
tony_smith
Pro Scripter
Posts: 70
Joined: Wed May 14, 2003 8:25 pm
Location: Vancouver BC Canada

Detecting Terminal Srvices Console

Post by tony_smith » Tue Jan 06, 2004 8:51 pm

I have been trying to find a way to detect if the console, for the machine running Macro Scheduler, is disconnected... if the console is unattended.

I run MS on a server and connect to it remotely using Terminal Services. This works pretty well 99 percent of the time. Unless, Terminal Services is disconnected by the system; usually a momentary connect problem.

Things run fine while disconnected, until MS needs to send a keystroke and that is when things become unhinged. I have tried using a WordPad session to fail the job (See below), but with poor results; the script cannot close Wordpad. The result is that many Wordpad sessions are left open and the server eventually runs out of resources and barfs.

Any ideas?

Remark>If WordPad is open from previous session, close it
IfWindowOpen>Document - WordPad,CLEARIT,BEGIN
Label>CLEARIT
Gosub>CLRSCN
Label>BEGIN
Run Program>"C:\Program Files\Windows NT\Accessories\wordpad.exe"
WaitWindowOpen>Document - WordPad
SetFocus>Document - WordPad
Press ALT
send>f
Release ALT
send>n
Let>WW_TIMEOUT=10
WaitWindowOpen>New
If>WW_RESULT=FALSE,STOP
//MessageModal>Window Open Successful
GoTo>End
Label>STOP
//MessageModal>Window Did Not Open
Remark> If child window fails to open, close Wordpad...
Remark> Add logic here to halt processes and advise operator
Label>End
Gosub>CLRSCN

//////Sub-Routines///////
Srt>CLRSCN
Press ESC
SetFocus>Document - WordPad
Press ALT
Wait>1
send>f
Wait>1
Release ALT
Wait>1
Send>x
End>CLRSCN

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts