Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script to send 'alt+ctrl+end' to a terminal server session

Status
Not open for further replies.

nyehus

MIS
Dec 13, 2012
4
0
0
GB
Hello,

my company has several pcs located around the company (different countries etc), each of these pcs is running a drone software
ie doing set up predefined steps, data entry, button clicks etc, to simulate the use of different applications
the time taken to run these scripts is recorded and shown on a dashboard - so network issues can be highlighted.

the first part of the drone script logs into a terminal server and from there accesses various environments.

the problem we have encountered is that sometimes the terminal server session hangs, so when the next script comes along it is unable to complete as the data on the screen is not matching what the script is looking for.

I have written small vbs script to try and send 'alt+ctrl+end' to the terminal server session (to bring up the 'windows security' menu) followed by 'alt+l' to logoff the terminal session - so that the next time the script runs it starts with a clean terminal server session.

but the vbs script does not appear to be working - see script below


Set objWshShell = Wscript.CreateObject("WScript.Shell")
WScript.Sleep(5) ' Give some time to load

While 1 = 1
check = objWshShell.AppActivate("mstsc")
If check = true then objwshshell.Sendkeys("%^{END}")
objwshshell.Sendkeys("%+'l'")
Wscript.Sleep(10)
Wend
WScript.Quit

I am crawling my way through understanding vbscripting and have copied code from google.
any pointers would be much appreciated

regards rob
 
oh yes I had forgotton about the shutdown command - Doh!

I have tried it, the problem i have is its needs the computer name, which I dont have as the script logs into the terminal server via a load balancer so it could go to anyone of 70 different terminal servers
 
the script runs locally - and starts up a rdp session, so logically I still haveto use -m otherwise it reboots the local machine

re the registry entry, I will try that, but these terminal servers are locked down prenty much
 
unabe to get the actual machine name from the registry key - it does hold a vale, but it is the generic load balancer id.

I can run '%%computernme%%' in the url bar of te terminal server sesson, which returns a window with the value of the machine name. So now I need to be able to capture thatimage and convert to txt, then copy that value Sounds long winded but my work.

I have put a request in to get the machine name listed on the index page that opens when the connection to the terminal server is opened - then I can capture it with my drone software
 
it does hold a vale, but it is the generic load balancer id.

Then check the load balancers registry. Or put a GPO or "logon" script in place that writes the name of the machine to a file on a network share. Open is an read the contents.

Things may be easier with your drone software but converting to an image and then back to text does not sound like a good solution.

-Geates

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top