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

后端 未结 8 1379
北海茫月
北海茫月 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:16

    ps2> start-job {start-sleep 20}
    

    i have not yet figured out how to get stdout in realtime, start-job requires you to poll stdout with get-job

    update: i couldn't start-job to easily do what i want which is basically the bash & operator. here's my best hack so far

    PS> notepad $profile #edit init script -- added these lines
    function beep { write-host `a }
    function ajp { start powershell {ant java-platform|out-null;beep} } #new window, stderr only, beep when done
    function acjp { start powershell {ant clean java-platform|out-null;beep} }
    PS> . $profile #re-load profile script
    PS> ajp
    

提交回复
热议问题