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.
This topic is 8 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
monoeagle
Posts: 108
Last visit: Fri Jan 26, 2024 10:44 am

Re: Progressbarproblems after Change to new Powershell Studi

Post by monoeagle »

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Progressbarproblems after Change to new Powershell Studi

Post by jvierra »

Looks OK to me.
This topic is 8 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked