How to disable tmp file when runs WinSCP DLL in VB Script

Advertisement

Justin Kuo
Guest

How to disable tmp file when runs WinSCP DLL in VB Script

I used the VB Script to call the WinSCP DLL.
The script is the same as the example posted in this web site.
However, the script generated a tmp file under "C:\Users\<username>\AppData\Local\Temp\" folder every time when the script was executed.
The content of the tmp file is below.
Can someone know how to disable the tmp file or delete it after script finished?

<?xml version="1.0" encoding="UTF-8"?>
<session xmlns="https://winscp.net/schema/session/1.0" name="monitor@TRANSFER.QGS.QLD.GOV.AU" start="2015-06-04T23:04:25.228Z">
<group name="open -hostkey=&quot;ssh-rsa 2048 a2:b5:f5:68:18:46:08:38:4d:e2:ad:86:59:f5:8f:66&quot; -timeout=15 &quot;sftp://monitor:123456@TRANSFER.QGS.QLD.GOV.AU&quot;" start="2015-06-04T23:04:25.511Z">
</group>
<group name="stat -- &quot;st11.txt&quot;" start="2015-06-04T23:04:25.708Z">
<stat>
<filename value="/st11.txt" />
<file>
<type value="-" />
<size value="0" />
<modification value="2014-06-01T14:00:00.000Z" />
<permissions value="rw-r--r--" />
</file>
<result success="true" />
</stat>
</group>
<group name="exit" start="2015-06-04T23:04:25.846Z">
</group>
</session>

Reply with quote

Advertisement

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

Re: How to disable tmp file when runs WinSCP DLL in VB Script

You cannot disable the temporary XML log, it's needed for the assembly to work. And the log should get deleted automatically, when the Session object is disposed.

Reply with quote

Justin Kuo
Guest

Re: How to disable tmp file when runs WinSCP DLL in VB Script

martin wrote:

You cannot disable the temporary XML log, it's needed for the assembly to work. And the log should get deleted automatically, when the Session object is disposed.

Hi Thanks for your reply.
But the tmp file didn't be deleted after the session object was disposed.
The tmp files caused the folder reached the limitation of Windows file count.
So my script stopped because no more tmp file could be generated.
My script is following.


Option Explicit

' Setup session options
Dim sessionOptions
Set sessionOptions = CreateObject("WinSCP.SessionOptions")
With sessionOptions
.Protocol = .Protocol
.HostName = "TSTTRANSFER.COM.AU"
.UserName = "u_monitor"
.Password = "123456"
.SshHostKey = "ssh-rsa 2048 c7:e9:40:70:f9:54:54:7c:ac:74:6c:75:a7:f4:32:8c"
End With

Dim session
Set session = CreateObject("WinSCP.Session")

Dim DateFile
DateFile = formatdatetime(NOW(),1)

Dim LogFile
LogFile = "C:\Program Files\WinSCP\tstscp_" & DateFile & ".log"
session.SessionLogpath = LogFile
session.DebugLogpath = DebugLog

' Connect
On Error Resume Next

session.Open sessionOptions
If Err.Number <> 0 Then
FireActions = True
Details = "Connection Failed. Please Check Logs."
Err.Clear
Else
' Upload files
Dim transferOptions
Set transferOptions = WScript.CreateObject("WinSCP.TransferOptions")
transferOptions.TransferMode = TransferMode_Binary

Dim transferResult
Set transferResult = session.PutFiles("c:\temp\Axway_test\*", "/", False, transferOptions)

' Throw on any error
transferResult.Check

' Print results
Dim transfer
For Each transfer In transferResult.Transfers
' WScript.Echo "Upload of " & transfer.FileName & " succeeded"
Next

End If
' Disconnect, clean up
session.Dispose

Reply with quote

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

Re: How to disable tmp file when runs WinSCP DLL in VB Script

Please attach a full debug log file showing the problem (using the latest version of WinSCP).

To generate log file, set Session.DebugLogPath. Submit the log with your post as an attachment. If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

Justin Kuo
Guest

Re: How to disable tmp file when runs WinSCP DLL in VB Script

I am using the version 5.0.6 on Windows 2008 R2.
I am not able to update it to the latest version 5.7.3 now.
The debug log is attached for your reference.
  • WinSCP_debug.log (26.59 KB, Private file)

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Re: How to disable tmp file when runs WinSCP DLL in VB Script

Sorry, but 5.0.6 is an ancient beta version (3 years old), first release of .NET assembly prototype. We cannot really provide a support for that. And you cannot expect it to work correctly.

Reply with quote

Justin Kuo
Guest

Re: How to disable tmp file when runs WinSCP DLL in VB Script

Hi prikryl,

I upgraded the dll to 5.7.3 then the tmp file was deleted after session disposed.
Thanks for your help.
:D

Reply with quote

Advertisement

You can post new topics in this forum