Multiple GB worth of wscp*.tmp files in C:\Windows\Temp

Advertisement

unix-bomber
Joined:
Posts:
6
Location:
Virginia

Multiple GB worth of wscp*.tmp files in C:\Windows\Temp

Hey all,

I recently had a requirement to build a powershell script that performs SFTP/FTPS transfers that would survive reboot.

Operation and security constraints lead to me running the script as a service, to survive reboot.

After allowing the service to run for a day, I noticed my HDD was full. As it turns out, there were several Gb worth of files like 'wscp1048.017658A6.tmp' in C:\Windows\Temp

The code I've been running is here
https://github.com/unix-bomber/Powershell
(WinSCP code starts at line 1006)

I have several MB of transaction logs as well (There's a log for each time WinSCp downloads, or enumerates a foreign directory)

So far I've read that files that are edited via WinSCP, may be temporarily stored in C:\Windows\Temp but I don't know why they would persist between sessions/ runs

If anyone has had this issue, or can point me in the direction of a resource that can help I would be quite grateful.

Reply with quote

Advertisement

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

Re: Multiple GB worth of wscp*.tmp files in C:\Windows\Temp

Does every WinSCP.Session instance leave a .tmp behind? Can you enable debug logging (Session.DebugLogPath) and attach the log here (for a session that left a .tmp behind).

Reply with quote

unix-bomber
Joined:
Posts:
6
Location:
Virginia

Re: Multiple GB worth of wscp*.tmp files in C:\Windows\Temp

It looks like there were 15 .tmp files left behind, from 20 Sessions. Some .tmp's were as small as 1KB and others as large as 300KB

I zipped the debug from one of the runs that had orphaned a .tmp

I was having issues uploading a zip, so I stored it here
https://drive.google.com/drive/folders/13onwOv6mhORt4TEj9DB4QGXtMm-BTRAp?usp=sharing
If that's not desirable I can continue to try to upload again later (perhaps it's the network I'm on)

(Potentially superfluous/ unnecessary info below)
The PFTS script installs as a Windows service, and executes a function (named 'run-pfts') every 30 seconds. The function in turn starts .ps1 files as jobs.

That said, there was one script running as a 'job handler' another script attempting to download files, and a third script attempting to upload files.

I noticed, that with debug mode on none of the files actually transferred

Reply with quote

martin
Site Admin
martin avatar

Re: Multiple GB worth of wscp*.tmp files in C:\Windows\Temp

The log is not finished. It looks like the process was aborted. The process was running for 2 minutes (almost exactly). Isn't there some check that aborts the process, if it does not finish within 2 minutes?

Reply with quote

unix-bomber
Joined:
Posts:
6
Location:
Virginia

Re: Multiple GB worth of wscp*.tmp files in C:\Windows\Temp

I'm a fool.

The issue was with part of my code. By using Receive-Job instead of Get-Job, I wasn't getting the state of the child jobs.

.tmp files are no longer being orphaned

Thank you for the help Martin!

Reply with quote

Advertisement

You can post new topics in this forum