Topic "Progress Bar shows momentarily using .NET in Powershell 4.0"

Author Message
mwetmore
[View user's profile]

Joined: 2014-05-23
Posts: 5
Location: Philadelphia, Pennsylvania US
Progress Bar shows momentarily using .NET in Powershell 4.0

Running in Powershell ISE or in CMD.EXE a progress bar flashes up for a moment. How to prevent this? The script will be run by a scheduler. Not using sync, just $session.PutFiles() and $session.GetFiles() for transfers, all piped to Out-Null.

BTW at https://winscp.net/eng/docs/library_example_listing_files_matching_wildcard this:

Code:
foreach ($fileInfo in $directory.Files)


should be:

Code:
foreach ($fileInfo in $Files)
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24995
Location: Prague, Czechia
What progress bar do you mean?
_________________
Martin Prikryl
mwetmore
[View user's profile]

Joined: 2014-05-23
Posts: 5
Location: Philadelphia, Pennsylvania US
When running the ps1 in 4.0 ISE by clicking Arrow to execute the console shows the full path to the script, then just before the script exits a GUI blue progress bar flashes up on the top of the console. It is a very quick flash, I have to be staring at the right place to see that the short disturbance.

Similarly when I run the script by invoking powershell in a cmd window, there is a quick flash of 'ooo...' that moves across the top of the window.

These are all the assembly methods used, in the order that they occur. The script runs in < 30 seconds

Code:

 # SFTP does not have an append verb so it has to be get->append->put
        $rem = "{0}{1}" -f $carrdir, $rcdf
        if ($send -eq "R" -and $session.FileExists($rem)) {
            if ($session.GetFiles($rem, $rcdtemp).IsSuccess) {
                $session.RemoveFiles($rem) | Out-Null
                Get-Content ($rcdtemp) |
                    Add-Content ("{0}\{1}" -f $temploc, $rcdf)
            } else {
                CleanUp-Exit(2)
            }
        }

Code:

        # This creates a directory in $carrdir named like $temploc
        $session.PutFiles($temploc, $carrdir).Check() | Out-Null

        # Get list of files uploaded
        $files = $session.ListDirectory($carrloc).Files | Where { -not $_.IsDirectory }

Code:

            # Move the files up into $carrdir
            ForEach ($fileinfo in $files) {
                $session.MoveFile($carrloc + "/" + $fileinfo.Name, $carrdir)
            }

Code:

   if ($session.Opened) {
        $session.RemoveFiles($carrloc) | Out-Null
        $session.Dispose()
    }
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24995
Location: Prague, Czechia
WinSCP .NET assembly does not present any progress bar (it has no GUI at all). So it has to be your run-time environment that shows the progress bar.
_________________
Martin Prikryl
Advertisements

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!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License