Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-18-2017, 01:34 PM
mschaafs mschaafs is offline
Registered User
 
Join Date: Oct 2017
Posts: 27
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...
Reply With Quote
  #2  
Old 12-18-2017, 02:56 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
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?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730

Last edited by ekoranyi; 12-18-2017 at 04:46 PM.
Reply With Quote
  #3  
Old 12-20-2017, 12:19 PM
mschaafs mschaafs is offline
Registered User
 
Join Date: Oct 2017
Posts: 27
Talking 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?
Reply With Quote
  #4  
Old 12-20-2017, 12:32 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
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
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 12-20-2017, 01:30 PM
mschaafs mschaafs is offline
Registered User
 
Join Date: Oct 2017
Posts: 27
Unhappy 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.
Reply With Quote
  #6  
Old 12-20-2017, 01:49 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi mschaafs,

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

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #7  
Old 12-20-2017, 01:51 PM
mschaafs mschaafs is offline
Registered User
 
Join Date: Oct 2017
Posts: 27
As I mentioned... I am running Javascript on SecureCRT version 8.3.1 (x64 Build 1537)
Reply With Quote
  #8  
Old 12-20-2017, 02:00 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
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?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #9  
Old 12-20-2017, 03:17 PM
mschaafs mschaafs is offline
Registered User
 
Join Date: Oct 2017
Posts: 27
Question 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?
Reply With Quote
  #10  
Old 12-20-2017, 03:33 PM
mschaafs mschaafs is offline
Registered User
 
Join Date: Oct 2017
Posts: 27
Thumbs up 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!
Reply With Quote
  #11  
Old 12-20-2017, 03:42 PM
mschaafs mschaafs is offline
Registered User
 
Join Date: Oct 2017
Posts: 27
Exclamation 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?
Reply With Quote
  #12  
Old 12-20-2017, 03:53 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
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?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #13  
Old 12-20-2017, 04:04 PM
mschaafs mschaafs is offline
Registered User
 
Join Date: Oct 2017
Posts: 27
Nice!

Boom! That is perfect. Thanks again!
Reply With Quote
  #14  
Old 12-20-2017, 04:06 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
mschaafs,

I'm glad to have been able to help. Have a great rest of the day.
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply

Tags
error , input locking , javascript , scripting , stop script


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 09:09 PM.