Welcome to the VanDyke Software Forums

Join the discussion today!

Go Back   VanDyke Software Forums > Scripting


Closed Thread
Thread Tools Rate Thread Display Modes
Old 10-17-2017, 03:21 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,099
Post Example: Get Configuration Path

In your scripts, do you ever need to derive the configuration folder location where SecureCRT is loading/saving config data? These examples (Python and VBScript) show you how you can accomplish this in SecureCRT 7.2 and newer versions.

This technique leverages the cross-platform support that was introduced in SecureCRT version 7.2, providing a map between substitution variables and actual file system path locations. One such substitution is ${VDS_CONFIG_PATH}, which maps to the actual configuration folder in use by SecureCRT.

In this technique, our script code executes the following steps in order:
  1. Pick a session option name that we can use to return a path. It doesn't matter which one, but for this example, we choose to utilize the "Upload Directory V2", which is used by SecureCRT to store the path where SecureCRT defaults to when browsing for files to upload (via x|y|zmodem transfers, for example).
  2. Read the current value of the "Upload Directory V2", stashing it in a variable (so that we can restore the original value later).
  3. Set the value of the "Upload Directory V2" option to ${VDS_CONFIG_PATH}.
  4. Save the config. This results in the ${VDS_CONFIG_PATH} substitution string literal being stored in the configuration for the session.
  5. Reload the session configuration.
  6. Get the value of the "Upload Directory V2" session option. In the process of returning the value of this option, SecureCRT will convert the ${VDS_CONFIG_PATH} substitution variable into the actual path that SecureCRT is using for loading/saving configuration data.
  7. Set the "Upload Directory V2" option to its original value.
  8. Save the config so that the changes are stored in the underlying .ini file.

So... which session is it that the script is manipulating in order to stash/set/read/restore the "Upload Directory V2" option?

It so happens that it's the session that's active when the script is launched. If you don't have any active connections (SecureCRT has just been launched, and you don't have any tabs/tiles open to any hosts yet) or if you've been using ad hoc connections then it's the Default session that is being manipulated.

Script examples for both Python and VBScript are included below.

Attached Files
File Type: txt GetConfigPath.py.txt (1.5 KB, 2866 views)
File Type: txt GetConfigPath.vbs.txt (1.6 KB, 2689 views)
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Closed Thread

config , example script , python , securecrt , vbscript

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 07:23 PM.