开发者

Running background processes (especially rails) in powershell on windows 7

How does one run a background process in powershell on windows 7? The answers here: Powershell equivalent of bash ampersand (&) for forking/running background processes refer to *-psjob commands which seem to no longer exist.

I have found one other reference through google to psjob being missing, but no solutions.

Edit: apparently the sol开发者_如何学运维ution involves a command called start-job.

UNFORTUNATELY it's not clear how to run a programme that takes parameters. I'm trying to run "rails server". When I just type rails server at the prompt, rails runs just fine, but it blocks my shell. I've tried various ways of invoking rails with the server argument, such as:

start-job -scriptblock {rails server}
start-job -scriptblock {"rails server"}
start-job -scriptblock {rails "server"}
start-job -scriptblock {rails} -argumentlist server
start-job -scriptblock {rails} -argumentlist "server"
start-job -scriptblock {rails $args[0]} -argumentlist server
start-job -scriptblock {rails $args[1]} -argumentlist server
start-job -scriptblock {rails $args[0]} -argumentlist @("server")

all to no avail


Try this

Start-Job -scriptblock { param($p) rails $p } -ArgumentList "server"


Random guess: Try fully-qualifying the path to rails.exe.


Have you tried using the New-PSSession cmdlet? This allows you to run commands under a new background session using PowerShell Remoting, even on the local machine.

$Session = New-PSSession localhost

Invoke-Command -Session $Session -ScriptBlock {Rails Server}

For more info:

help about_remote*


It's not very elegant but you could always make a batch file and call that. I do that for calling curl from PowerShell.


Have a look to the function in powershell - passing parameters to exe

The function Call can interest you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜