View Single Post
  #3  
Old 04-08-2019, 03:39 AM
ogun ogun is offline
Registered User
 
Join Date: Sep 2013
Posts: 15
If you are looking for the full file system path, I use the following:

Code:
def get_config_path():
    """ Find path of SecureCRTs configuration """

    # This could be done using the config variable trick, this one has been proven to work on
    # many version of SecureCRT.
    if os.name == "nt":
        # We're on windows, use the registry
        import _winreg

        try:
            key = _winreg.OpenKey(
                _winreg.HKEY_CURRENT_USER, "SOFTWARE\\VanDyke\\SecureCRT"
            )
            config_path = _winreg.QueryValueEx(key, "Config Path")[0]
            _winreg.CloseKey(key)

            if "%" in config_path:
                config_path = _winreg.ExpandEnvironmentString(config_path)
            log.debug("Config path (Win): %s", config_path)
            return config_path
        except Exception as e:
            crt.Dialog.MessageBox(str(e))
    elif os.name == "posix":
        # We're on linux, read the config file
        try:
            import ConfigParser

            config_file = os.path.expanduser("~/.config/VanDyke/SecureCRT.conf")
            config = ConfigParser.ConfigParser()
            config.read(config_file)
            config_path = config.get("General", "Config%20Path")
            log.debug("Config path (Lin): %s", config_path)
            return config_path
        except Exception as e:
            crt.Dialog.MessageBox(str(e))
    else:
        crt.Dialog.MessageBox("Unknown os")
This will return the file system path of the configuration folder, just append "Sessions" to this you will get the path of the session files.
Not tested on versions below 8.0 but I see no reason why it shouldn't work.
Reply With Quote