Datacopier for DaRT

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 5 years and 1 month 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
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Datacopier for DaRT

Post by apowershelluser »

Hello,

I'm trying to copy specific folders (33) from a local PC that cannot boot, to our fileshare using PowerShell and Robocopy

This was not an easy process as some folders we need subfolders and some, we only need certain files.

I can't seem to get the progress bar to wait after the folder is completed to perform a step. It will however just move on its own :D

Do I need to create separate jobs for each folder?
DummyDART-Distribute.psf
(53.96 KiB) Downloaded 131 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Datacopier for DaRT

Post by jvierra »

You progress bar is too short. You need to output steps from the jobscript and use the output to increment the progress bar. With a copy there is no way to accurately predict the time that it will take.
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Datacopier for DaRT

Post by apowershelluser »

if you could provide me an example of what you mean using my form. I would greatly appreciate it.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Datacopier for DaRT

Post by jvierra »

The issue is that you haven't really understood what a progress bar is and how it works.

For a good discussion on the Pbar right click on the control in the toolbox and read the documentation and the Spotlight article. The article and docs will show you how the pbar is intended to be used and give you examples of the usage and parameters.
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Datacopier for DaRT

Post by apowershelluser »

While I appreciate your biased opinion. This is not my first form. Not the first one I’ve had with a progress bar or even with jobs.

It is however my first with this many different folders to capture.

I will happily take your No and move on. Sorry for wasting anyone’s time.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Datacopier for DaRT

Post by jvierra »

Sorry but I cannot write a whole lot of custom code for you. Your approach to the issue is a bit faulty if you want to use a progress. The best you can do is to output a step number after each RoboCopy and receive that in the update script. Set the progress bar for the number of steps.

The progress bar and its use have been an issue with programmers and with designers in installers. There is no way to know how long an arbitrary set of commands will take. This makes the pbar a best guess arrangement.

The issue is that I can point you in the right direction but you need to fully understand the pbar and design a method for your code to use it within its limitations. Reading the documentation is the place to start. Without a full understanding of how it works you will not be able to design a solution that suits your needs,

My opinion is only biased by 30+ years of using and designing progress indicator. I think I know what I am talking about.

When baffled by the technology its time stop and rethink what you are doing. Try a new approach. Search for articles that discuss the issue. Eventually you will be able to find a solution that is acceptable.
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Datacopier for DaRT

Post by apowershelluser »

I'm sorry I was hoping my provided form gave you enough to not think I want custom code, just a nudge in the right direction :D

This is not my first time trying to tackle this problem and have spent many hours trying to get this working.

I have set the Pbar maximum to the equal amount of folders I need to copy, this is why I'm baffled.
User avatar
mxtrinidad
Posts: 399
Last visit: Tue May 16, 2023 6:52 am

Re: Datacopier for DaRT

Post by mxtrinidad »

Every situation is different.

Your script need more care:
1. Everything that is repetitive can be converted to a function. ( function My-Robocopy{(param folder, options..)..} )
2. Use Try/Catch - if something happens to the Robocopy step, then what to do.
3. Need to build custom messages during your process. This will help to trace your process flow.
4. Use "run process" instead of job. This will help have more control over the code, and specially when debugging. You can't debug in a background job.

Progress Bar increment in a nutshell:
For example:
1. Initialize the Progress Bar
$progressbar1.Maximum = ##-Max number of Robocopy steps-###;
$progressbar1.Step = 1;
$progressbar1.Value = 0;

2. Moving to increment the progress bar after each Robocopy has completed:
$progressbar1.PerformStep();

:)
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Datacopier for DaRT

Post by jvierra »

Max has a good suggestion. I would just output numbers from the job. Output the step number and set the progress bar to that number. The pbar will display the correct value as the steps progress.

For this I would actually NOT use a pbar. I would just output the text returned by RoboCopy to a textbox. You can also turn on the RC progress output and that would entertain the user while the copy is running.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Datacopier for DaRT

Post by jvierra »

Here is one of my old demos showing how to use a job tracker to report on a long running job as it progresses.
Attachments
Demo-SimpleJobTracker.psf
(26.65 KiB) Downloaded 124 times
This topic is 5 years and 1 month 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