VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Input Locking While Running? (https://forums.vandyke.com/showthread.php?t=12951)

mschaafs 12-18-2017 12:34 PM

Input Locking While Running?
 
Good day! I am wondering if there is a way to keep SecureCRT from accepting keystrokes or right clicks while it is running a script. We have sensitive processes running and if someone accidentally types something or right clicks (pasting the clipboard contents)... it can at best crash the script, at worst inadvertently cause unintended commands to execute. Thank you...:confused:

ekoranyi 12-18-2017 01:56 PM

Hi mschaafs,

There is!

Changes in SecureCRT 8.3 (Beta 1) -- September 21, 2017
-------------------------------------------------------
- Added the ability to script session locking from the Session object.

Lock
Description
Locks the current session (or all sessions).
Remarks
All the parameters are optional. The default for prompt is false. If prompt is true, the Lock Session dialog will be displayed. The default for password is the empty string ("") and the default for lockallsessions is false.
Syntax
object.Lock([,prompt [,password, [,lockallsessions]]])
As an example you could use:

Code:

crt.Session.Lock
<your code>
crt.Session.Unlock

This would silently lock the session preventing input, unlocking when you're ready to release control.
Does this give you the functionality you're looking for?

mschaafs 12-20-2017 11:19 AM

Wonderful!
 
Hello! Thank you... that is fantastic. Do dialog boxes work while the Lock is in place? Such as crt.Dialog.MessageBox and crt.Dialog.Prompt?

ekoranyi 12-20-2017 11:32 AM

Hi mschaafs,

They sure do, I've included some example code to demonstrate this.

Code:

# $language = "VBScript"
# $interface = "1.0"

crt.Session.Lock

strInput = crt.Dialog.Prompt("Please enter some input", "Test Prompt", "")
crt.Dialog.MessageBox strInput

crt.Session.Unlock


mschaafs 12-20-2017 12:30 PM

Trouble...
 
I am getting a failure on this... in Javascript on version 8.3.1:

crt.Session.lock();
crt.Session.unlock();

"Microsoft JScript runtime error

Error: Object doesn't support this property or method"

Please help? Thank you.

ekoranyi 12-20-2017 12:49 PM

Hi mschaafs,

This feature became available in SecureCRT 8.3 (Beta 1). What version of SecureCRT are you running (Help > About SecureCRT)?

mschaafs 12-20-2017 12:51 PM

As I mentioned... I am running Javascript on SecureCRT version 8.3.1 (x64 Build 1537)

ekoranyi 12-20-2017 01:00 PM

Hi mschaafs,

I apologize I missed the version.

It's interesting, I created a .js file with the following:

Code:

crt.Session.lock();
crt.Sleep(3000)
crt.Session.unlock();

I'm also running Version 8.3.1 (x64 build 1537) and the script runs without issue.

Can you provide the full script you are attempting to run and the full error message including the line the error is occurring on?

mschaafs 12-20-2017 02:17 PM

Curiouser and curiouser...
 
So, yeah, I created a small script and was able to make it work... however, when I copy that same line to my larger script, I get the error, no matter it's placement in the script. The only difference I can see between them is that the one with the error has a session being launched via Excel Macro:

Code:

nResult = objShell.Run( _
        Chr(34) & securecrt_path & Chr(34) & " /SCRIPT " & script_init_path & _
        " " & arguments & _
        " " & protocol & " /PASSWORD " & strPassword & _
        " " & strUsername & "@" & host, 5, True)

Any thoughts on that?

mschaafs 12-20-2017 02:33 PM

Figured it out
 
Apparently, when I ran the upgrade to 8.3.1, it didn't remove the 8.0.4 version... which is the one Excel is launching. Thank you very much for the help and for the new feature! It is a beautiful thing! Happy holidays and New Year!

mschaafs 12-20-2017 02:42 PM

One more thing...
 
I was able to run it now... but I found that with it Locked and running, Crtl-C doesn't stop it, nor can I just close the session to do so. I was able to stop it via the Task Manager, but that is not elegant for an application. Is there a way to halt execution or create a way for a user to unlock the session in an emergency?

ekoranyi 12-20-2017 02:53 PM

Hi mschaafs,

I'm glad to hear you were able to get it up and running.

The user can always right click on the sessions tab and choose Unlock Session.

Does this allow you to use it in the way you would like?

mschaafs 12-20-2017 03:04 PM

Nice!
 
Boom! That is perfect. Thanks again!

ekoranyi 12-20-2017 03:06 PM

mschaafs,

I'm glad to have been able to help. Have a great rest of the day.


All times are GMT -6. The time now is 11:26 AM.