Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

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.
Carito

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