Cant get Powershell window to close after calling winscp

Advertisement

Carito
Guest

Cant get Powershell window to close after calling winscp

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\WinSCP.com"

#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'

Thanks

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Cant get Powershell window to close after calling winscp

This does not seem to be WinSCP related. Anyway, how do you run PowerShell? Also attach a screenshot.

Reply with quote

Advertisement

You can post new topics in this forum