VanDyke Software Forums

VanDyke Software Forums (
-   Scripting (
-   -   Input Locking While Running? (

mschaafs 12-18-2017 01: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 02: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.

Locks the current session (or all sessions).
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.
object.Lock([,prompt [,password, [,lockallsessions]]])
As an example you could use:


<your code>

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 12:19 PM

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 12:32 PM

Hi mschaafs,

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


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


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


mschaafs 12-20-2017 01:30 PM

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


"Microsoft JScript runtime error

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

Please help? Thank you.

ekoranyi 12-20-2017 01: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 01:51 PM

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

ekoranyi 12-20-2017 02:00 PM

Hi mschaafs,

I apologize I missed the version.

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



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 03: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:


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 03: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 03: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 03: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 04:04 PM

Boom! That is perfect. Thanks again!

ekoranyi 12-20-2017 04:06 PM


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 08:45 AM.