Topic "Cant get Powershell window to close after calling winscp"

Author Message


Im launching winscp to transfer a file. It works great but I cannot figure out how to get the powershell window to close. I have close and exit at the end. What happens is it echos back on the screen Session closed no session but it doesn't exit, it just stays like its waiting something. The only way I can get back to the prompt is a control c.

Id really like it to just connect, transfer, close, and exit....BTW if i use WinSCP.exe instead of com then Powershell launches a separate window which does close but the 1st is left behind. Can someone help?

$localfile = 'C:\folderA\* '
$remoteloc = '/home/ms/folderB/'
$movefile = '"put '+ $localfile + $remoteloc + '"'
$winscp = "c:\Program Files (x86)\WinSCP\"

#Connection string format username:password@appliance_name:port#
$FWconn = '"open sftp://username:password@servername:port"'

Start-Process -NoNewWindow -PassThru -FilePath $winscp -ArgumentList '/console', '/command', $FWconn, '"option batch aborzt"', '"option confirm off"', '"option transfer binary"', $movefile, 'close', 'exit'

[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24736
Location: Prague, Czechia
This does not seem to be WinSCP related. Anyway, how do you run PowerShell? Also attach a screenshot.
Martin Prikryl

You can post new topics in this forum

Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License