Link to home
Start Free TrialLog in
Avatar of qeng
qeng

asked on

VBS Script to click a button in a Terminal Session

I've written a VBS script which automatically loads a script-defined secure webpage (https://)  in IE and submits a user's log-in credentials.

This causes a second webpage to load in a second tab (which becomes the active tab) in IE.

I know the name of the second page (let's say it's URL = "http://domain.com/secondpage")

My script then clicks on a link on this second page.  This causes the webpage to start a Terminal Session on a remote computer (my work computer).

My work computer (or terminal server? ... I'm out of my depth here) open a new page? with an OK button (this page no longer appears to be within a browser; I assume it is in a terminal window; for example, if minimized, this window shows up on the taskbar as a separate 'app' window with my work computer's ID such as 'CorpPC1234').

I would like to add an action to my existing script (or have my script call another script) to click the OK button on the page the terminal session served (this is part of a secondary log-in sequence).  If I can at least get past this OK button, I can then continue to automate the next log-in steps on subsequent terminal pages.

My problem is that unlike when I'm in the browser where I can target elements using for example the .getElementbyID function, once I'm in the Terminal Session I no longer know how to inspect the page or it's elements or tags or objects.

How can I go about this?
Avatar of qeng
qeng

ASKER

The first and second webpages my script navigates through are served by Junos Pulse Secure Access Service.  This is the service which launches the Terminal Session referred to above.
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Above is using Junipert Network Connect, the other technology used by Juniper very simular to Pulse. With JunOS Pulse we use the full client to get a networked connection, which again allows us to use direct RDP we can supply credentials aso. much better.
Avatar of qeng

ASKER

Qlemo,

Thanks for the input.  I'm not sure how to use the advice though short of looking into SendKeys (which I'm not familiar with).

Can my initial VBS login script be appended to send a keystroke command (if I put a suitable delay in) which would be seen by the Terminal Session?

If so, what would the VBS commands be to trigger this send?
Avatar of qeng

ASKER

The last few pieces I need to add to my script are:

add a delay
send a return keystroke
add a delay
send a return keystroke
send a password
send a return keystroke
Avatar of qeng

ASKER

Qlemo, my apologies.  When you mentioned SendKeys, I thought it was a third party app to 'send keystrokes' and not a WshShell command, hence my comment.  I'm brand new to scripting.


I've used WshShell.SendKeys "{ENTER}" etc. along with delays where I thought I needed them.

The problem I have left is that the correct keystrokes seem to be getting sent but they are not sent into the Terminal Session my script got me logged into, they are sent to the original desktop session where the script started executing (this is likely not the correct IT terminology).

How can I target the sent keystrokes to go be applied to the Terminal Session which Junos Pulse Secure Access Service started after my script logged me in.
Avatar of qeng

ASKER

I'm guessing (strictly a guess) that I have to first set the object to be the terminal session window prior to sending my keystrokes (otherwise they are sent to the original object?) but I don't know how to do that.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of qeng

ASKER

thx Qlemo,

I'm assuming that "start of window title or Process ID" is a label which I'm to change to whatever my window title or Process ID is.  Is that correct?

If it is, how can I inspect (figure out) what the window title or Process ID is (for example by using some equivalent to a Task Manager when you want to know which tasks are active)?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of qeng

ASKER

Using Windows Task Manager, I can see that under the Applications Tab, it lists the active Tasks.

     -  The Task i'm interested in targeting to send my keystrokes is called (for example):  ABCD123456

Also using Windows Task Manager, I can see under the Processes Tab, that it lists the Image Name.

     -  The Image Name I'm interested in targeting to send my keystrokes is called (for example):  dsTermServ.exe

Do I use the WshShell.AppActivate command in my VBScript with the Task Name, or the Image Name or neither?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of qeng

ASKER

Thx.  I will try this and get back.
Avatar of qeng

ASKER

I have not had a chance to get back to this issue.  My problem is still trying to target the terminal session with the keystrokes.
Eventually I had the opportunity to test with JunOS Pulse dsTermServ, and as expected no dice. The process ignores SendKey, at least for login stuff.
The only way able to perform automted actions in the terminal session is (probably) by running an application remote. That would, however, require you to have access outside of the terminal session - unlikely.

On another note, why can't you just execute whatever you need on the remote system, e.g. as scheduled task?
Avatar of qeng

ASKER

Qlemo,

Thanks for checking this.

I'm not sure what you mean by 'why can't you just execute whatever you need on the remote system'.

The sequence of actions I'm trying to automate is one I have to use dozens of times a day which involves having to log-on to our corporate network.  I do this from home, as well as while I'm moving around within the company (everytime I close my laptop, such as when going from one meeting to another, I have to log back in).

For now, I've been able to automate the my remote access up to the point where the remote server serves the login page which I would normally see if I were logging in to my desktop at the office.

It's at that point that I lose the ability to execute any further commands from my script, or more particularly, that I don't know how to interact with the active terminal session (my terminology).

So I'm not sure what you mean by using a scheduled task (in this context).
I'm still not clear why you should need to dig thru several web pages and click a lot of buttons just to get access to your office. This sounds like intentional abstruction. There are better ways to get secure access. E.g. Pulse allows a network connection, and that again opens up options for remote control.

As hinted before, you are out of luck without changing the login procedure. After having logged in, options are available again to start automation.
Avatar of qeng

ASKER

Qlemo, thanks.  

I'll try to explain this in a subsequent post but have sent in a support question to see if this question can be continued in privacy mode.  I don't want to expose any system vulnerabilities in providing the additional information i'd like to share here.
Avatar of qeng

ASKER

Thanks Qlemo,

I'll upgrade to cut down on some of the exposure for some of my questions but understood as it relates to visitors and member access to the questions.

I'll close off this question and email you the specifics in case there is any additional clarity you can help me gain. I'll do that by way mostly of screen grabs which should be fairly obvious to you since you're already pretty tuned in to this topic. I'll assume unless you advise otherwise that the contents of my email to you will remain 'private' (I'll hideout the credentials and corporate identifiers).

It may well be that I can't advance my 'automation' quest any further (I certainly don't doubt your advice, it's more that I may not be explaining things as clearly as necessary to give you the right info to help me on) but my gut tells me that if I can send the required information at some step in my process via the keyboard, there must be some way that at the very least, I can have on my laptop, some service running in the background which responds to some custom keyboard shortcut, regardless of whether i'm in a terminal session or not.  Presumably, with the right background process running, the system would respond to that short cut the same way  as it responds to function keys being pressed when I'm just entering the terminal session.

Thx for your feedback.
Avatar of qeng

ASKER

This problem doesn't appear to be straightforward.  Although I wasn't able to accomplish what I was hoping for, Qlemo provided good support and insight into the problem.  I will revisit this issue when I have more time available to troubleshoot further and have addressed potential privacy issues.