Powershell equivalent of bash ampersand (&) for forking/running background processes

后端 未结 8 1389
北海茫月
北海茫月 2020-11-28 20:33

In bash the ampersand (&) can be used to run a command in the background and return interactive control to the user before the command has finished running. Is there an

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-28 21:20

    You can use PowerShell job cmdlets to achieve your goals.

    There are 6 job related cmdlets available in PowerShell.

    • Get-Job
      • Gets Windows PowerShell background jobs that are running in the current session
    • Receive-Job
      • Gets the results of the Windows PowerShell background jobs in the current session
    • Remove-Job
      • Deletes a Windows PowerShell background job
    • Start-Job
      • Starts a Windows PowerShell background job
    • Stop-Job
      • Stops a Windows PowerShell background job
    • Wait-Job
      • Suppresses the command prompt until one or all of the Windows PowerShell background jobs running in the session are complete

    If interesting about it, you can download the sample How to create background job in PowerShell

提交回复
热议问题