Start-Job New Script

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.
Locked
jats1992@gmail.com
Posts: 3
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Fri Jan 25, 2019 4:05 pm

Start-Job New Script

Post by jats1992@gmail.com »

Hi All,

I have to Execute PS1 script when a button is clicked, if i add the script code to the button so the UI is not responsive for 10 min as the task is huge so i want to execute the script in different/background job.

So at the button i have added below code:
$path = .\Something.ps1
Start-Job -FilePath $path -Name "New Job"

But when i am done compiling it is not working as it is unable to find the script. I dont want to add the script in the same folder where i have compiled EXE.

Please help me with above, any help would be appriciated.

jats1992@gmail.com
Posts: 3
Joined: Fri Jan 25, 2019 4:05 pm

Re: Start-Job New Script

Post by jats1992@gmail.com »

is there any other way around.

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

Re: Start-Job New Script

Post by jvierra »

You need to use the full path to the script wherever you may have it stored.

There is no way to help you beyond that because we don't have any idea of what your code is or how you "compiled" it.

Be aware that scripts are not compiled, they are "packaged" which just stores the script inside of an EXE and executes the script directly.

Locked