VanDyke Software Forums

VanDyke Software Forums (
-   Scripting (
-   -   Script for Logfile Overwrites Session Properties (

dlong 03-23-2018 10:18 AM

Script for Logfile Overwrites Session Properties
Wondering how to specify a logfile location within a VBS script, but to not have the default logfile location changed after running the script.

bgagnon 03-23-2018 10:39 AM

Hi dlong,

I am not sure what you mean. Please provide specifics as to the behavior that is happening vs the desired behavior.

Are you using the LogUsingSessionOptions method (and LogFileName property)?

If you want to use a location other than what is saved in a session or Default Session, you might capture the original into a variable that you can restore at the end of your script.

Or use other mechanisms for log file creation (such as VBScript's OpenTextFile() function available when using a FileSystemObject). This way of logging is illustrated in the RunCommandsOnMultipleHostsAndLogResults example script here.

dlong 03-23-2018 11:09 AM

Hi Brenda,

I am using the crt.Session.LogFileName property to specify a log location, and I try to reset the logfile location at the end, but all subsequent sessions use the "LD117" file structure.

logfile = "C:\files\secureCRT\MyLocation\LD_117_ERL_" & strYear & "-" & strMonth & "-" & strDay & "_" & strHour & strMin & StrSec & ".txt"
crt.Session.LogFileName = logfile

' Enable logging
crt.Session.Log True

(stuff gets captured)

crt.Session.Log False
logfile = "C:\files\secureCRT\MyLocation\%Y-%M-%D_%h-%m-%s.txt"

UPDATE: My bad. I was not adding in the command to set the logfile at the end: crt.Session.LogFileName = logfile

bgagnon 03-23-2018 11:20 AM

Hi dlong,

You beat me to it. I am glad to hear you were able to resolve the issue. Thanks for posting the update. Have a great weekend!

bgagnon 03-23-2018 11:32 AM

1 Attachment(s)
Hi dlong,

Our scripting guru suggested the method illustrated in the attached script.

All times are GMT -6. The time now is 07:57 AM.