techahold / rustdeskinstall

Easy install Script for Rustdesk
MIT License
357 stars 110 forks source link

using start-process instead of start #12

Closed CvH closed 2 years ago

CvH commented 2 years ago

I have to admit that I am far away from a skilled powershell user so maybe this isn't the best idea or I misunderstood the purpose :)

Currently it is used that way

Start "$env:ProgramFiles\RustDesk\RustDesk.exe" "--password $random_pass"

Start-Sleep -s 5

So rustdesk is started and a sleep guarding the process to hopefully finish before the 5secs are over.

Why not use Start-Process with -wait to wait till the process is finished ? So it really waits till the job is finished and avoids errors if it takes longer then the sleep.

Start-Process "$env:ProgramFiles\RustDesk\RustDesk.exe" -argumentlist "--password $random_pass" -wait Start-Process "rustdesk-$restdesk_version-putes.exe" -argumentlist "--silent-install" -wait

dinger1986 commented 2 years ago

I have had some varying results in the past with -wait at least with the sleep I know its doing what I want it to do, although it does mean on a fast machine it can take a while, I will do some testing on this, thanks :)

CvH commented 2 years ago

The problematic part is not that it takes a while, I had the case that 5sec sleep was not enough (HDD spin up ...) so the next command was started regardless if the other command finished or not.

From what I understand at PS "start" is not intended to get used in those cases at all.

I have a stripped down version of the script and I didn't saw any unwanted stuff from Start-Process, but like said

I am far away from a skilled powershell user

dinger1986 commented 2 years ago

lol ok, ill do some tests and close this either way with the results of my tests.

dinger1986 commented 2 years ago

tested and changed now