Run Start-Job without a window

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 10 years and 6 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
SSC365
Posts: 23
Last visit: Fri Aug 21, 2020 6:26 am

Run Start-Job without a window

Post by SSC365 »

Hello,

There is a button in my GUI form and if you click it, you will trigger:

$test=Start-Job -ScriptBlock $script -ArgumentList $l_arg -Credential $cred | Wait-Job | Receive-Job

During this action, one black window shortly appears.

How can I avoid it?

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

Re: Run Start-Job without a window

Post by jvierra »

Depends on what is in the scriptblock.
User avatar
SSC365
Posts: 23
Last visit: Fri Aug 21, 2020 6:26 am

Re: Run Start-Job without a window

Post by SSC365 »

Test-Path is in the scriptblock.

$script={& test-path @args }
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Run Start-Job without a window

Post by davidc »

FYI, I moved this post to the PowerShell GUIs forum.

What are you using to create the GUI? PowerShell Studio has a Control Set that triggers a job from a button press without freezing the UI.

David
David
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Run Start-Job without a window

Post by jvierra »

It doesn't do that for me.

What is the purpose of that code. It is not very useful.

Without a complete script that is in the block no one can guess at what is happening.
User avatar
SSC365
Posts: 23
Last visit: Fri Aug 21, 2020 6:26 am

Re: Run Start-Job without a window

Post by SSC365 »

Thank you for your answers.

Test-Path doesn't work with -Credential. This is the reason why I used Start-Job.

In the future I will use Control set Start Job.
This topic is 10 years and 6 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