在后台运行exe [英] Run exe in background
本文介绍了在后台运行exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试了以下方法:
Start-Process powershell -ArgumentList "C:\Program Files\Prometheus.io\prometheus.exe" -WindowStyle hidden
Invoke-Command -ComputerName . -AsJob -ScriptBlock {
'C:\Program Files\Prometheus.io\prometheus.exe'
}
Start-Job -Name "prometheus" -ScriptBlock {Get-Process prometheus.io}
Start-Job {& .\prometheus.exe}
有时它会启动但在启动后立即终止.如果我手动启动它,它可以正常工作.
Sometimes it starts but terminates immediately after starting. If I start it manually it works correctly.
如何让我的进程在后台保持活动状态?
How can I keep my process alive in background?
它不起作用,因为我不在需要未设置路径文件的文件的进程目录中.
It doesn't worked because i wasn't in the directory of my process that need a file which pathfile is not set.
推荐答案
您的 Start-Process 语法错误,您不需要引用 powershell,只需使用 WindowStyle
参数启动您的程序设置
Your syntax for Start-Process is wrong, you don't need to reference powershell, just launch your program with the WindowStyle
param set
Start-Process "C:\Program Files\Prometheus.io\prometheus.exe" -WindowStyle Hidden
WorkingDirectory
参数也可用于在特定目录中启动程序
The WorkingDirectory
param can also be used to start the program in a specific directory
Start-Process "C:\Program Files\Prometheus.io\prometheus.exe" -WorkingDirectory "C:\Program Files\Prometheus.io" -WindowStyle Hidden
这篇关于在后台运行exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文