RE: VBA Scripting Issue with Session Logging - Access Denied on Log File (But Log Is Created!)

Advertisement

markvbauser
Joined:
Posts:
1

RE: VBA Scripting Issue with Session Logging - Access Denied on Log File (But Log Is Created!)

Hi Martin,

I am using the .NET assembly with VBA example and it works!

BUT, my client I am coding this for is unable to upload files like I can, so I am trying to figure out why their PC setup is not the same as mine.

This is an Excel application with VBA programming, and as said, it is working for me!

They can use WinSCP GUI application ok for connecting to the host server and doing file transfers, so that probably is ok.

But got the bright idea to log the session (your VBA example does not show this!!)...and added the log file path+name to session properties...and that did put lots of logging info into my log file...

HOWEVER...the process fails to complete correctly, and it seems the logging tries to re-open the log file but it is already open, causing Access Denied (my guess anyway)...

Here is relevant part of log file...took out confidential info...email me if you want the whole thing...suggest trying it...as it failed when added to VBA code that otherwise is working...

VBA code added to your VBA example: ...variable holds the log path...
...log path is ok as it is writing log info to the log file...but then errors out...WHY???
'Enable session logging
'rEF: https://winscp.net/eng/docs/logging
'REF: https://winscp.net/eng/docs/library_session#sessionlogpath
If SFTP_Session_Log_Path <> "" Then
  mySession.SessionLogPath = SFTP_Session_Log_Path
  mySession.DebugLogPath = SFTP_Session_Log_Path
Else 'default to no logging
  mySession.SessionLogPath = ""
  mySession.DebugLogPath = ""
End If
[2024-06-21 13:26:18.381] [0001]             Output: [winscp> open "sftp://<login>:<host>:2222" -hostkey="ssh-rsa 4096 <fingerprint>" -privatekey="H:\3-CLIENTS\<path>client_4096.ppk" -timeout=15]
[2024-06-21 13:26:18.381] [0001]             Output: [Error occurred during logging. It's been turned off.]
[2024-06-21 13:26:18.381] [0001]             Output: [Can't open log file 'H:\3-CLIENTS\<log path>'.
]
[2024-06-21 13:26:18.381] [0001]             Output: [System Error.  Code: 5.
]
[2024-06-21 13:26:18.381] [0001]             Output: [Access is denied]
[2024-06-21 13:26:18.381] [0001]             Output: [Searching for host...]
[2024-06-21 13:26:18.381] [0001]             Output: [Connecting to host...]
[2024-06-21 13:26:18.381] [0001]             Output: [Authenticating...]
[2024-06-21 13:26:18.381] [0001]             Output: [Using username "<user id>".]
[2024-06-21 13:26:18.381] [0001]             Output: [Authenticating with public key "<public key>".]
[2024-06-21 13:26:18.442] [0001]             Waiting for log update and dispatching events for 100
[2024-06-21 13:26:18.551] [0001]             Waiting for log update and dispatching events for 200
[2024-06-21 13:26:18.756] [0001]             Waiting for log update and dispatching events for 400
[2024-06-21 13:26:19.165] [0001]             Waiting for log update and dispatching events for 800
log repeats this for a bit...then session is broken...

ALSO, would like to know how VBA can handle error check: transferResult.Check
I am trying to figure out if my client's PC SFTP session opens ok and it does not do file upload as expected, etc. ...I have added progress messages into the script to try and debug code which I am not sharing with client, but is running on their machine (challenge)...but regardless, fails on my PC that works except after adding WinSCP session logging...which almost works, but has the access denied error during processing...that is in your camp I believe...let me know if you get it working on your side without that error.

Thanks!
Mark
mark@markfreeman.info
Chicago

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,041
Location:
Prague, Czechia

Re: RE: VBA Scripting Issue with Session Logging - Access Denied on Log File (But Log Is Created!)

Please post complete debug and session log as private attachments.

Reply with quote

Advertisement

You can post new topics in this forum