Progressbarproblems after Change to new Powershell Studio

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
monoeagle
Posts: 107
Joined: Tue Oct 13, 2015 9:10 am

Re: Progressbarproblems after Change to new Powershell Studi

Post by monoeagle » Fri Oct 23, 2015 3:22 pm

Hi David,
Hi jvierra,

thanks a lot for your help. It seems to work.
If the amount is big the progressbar runs slow as the copy process is work.

Code: Select all


# initiate
		$pgb_robocopy.Value = 0	
		$global:currentcnt = 0
		$global:totalcnt = (Robocopy "C:\Quelle" "C:\Ziel" /MIR /S /ETA /L /NC /NP).length - 1
				
		#Create a New Job using the Job Tracker
		Add-JobTracker -Name "JobName" `
					   -JobScript {
			#--------------------------------------------------
			#TODO: Set a script block
			#Important: Do not access form controls from this script block.
			
			Param ($Argument1)#Pass any arguments using the ArgumentList parameter
			
			
			robocopy "C:\Quelle" "C:\Ziel" /MIR /S /ETA /NC /NP /R:10 /W:10 /TEE /LOG:"C:\temp\logfile_$(get-date -f MM-dd-yyyy).log"
			#--------------------------------------------------
		}`
					   -UpdateScript {
			Param ($Job)
			
			$global:currentcnt += ($Job | Receive-Job).Count
			$percent = ($global:currentcnt / $global:totalcnt) * 100
			
			if ($percent -lt 100)
			{
				$pgb_robocopy.Value = $percent
			}			
		}`
					   -CompletedScript {
			Param ($Job)
			$pgb_robocopy.Value = 100
		}
Do you have something complain about?
In the Direction good practice?

greetings
monoeagle

jvierra
Posts: 13882
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Progressbarproblems after Change to new Powershell Studi

Post by jvierra » Fri Oct 23, 2015 3:29 pm

Looks OK to me.

Locked