首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >等待-进程在Windows 10中不工作

等待-进程在Windows 10中不工作
EN

Stack Overflow用户
提问于 2017-06-30 15:25:04
回答 2查看 1.5K关注 0票数 1

我有一个.ps1脚本来安装一个带有等待进程的软件,这个进程是在一台W7机器上用ISE创建的,当我试图在W10上运行它时,它会出错。下面是直到失败的脚本:

代码语言:javascript
复制
#Runs EnterpriseRx installer configured for PROD:
.\"EnterpriseRx.exe" /q /installType=0 /facilityID=999 /targetEnv=PROD 
/encryptFacility=0 /S /D=C:\McKesson\EnterpriseRx Production

#15 second notification letting user know install is running:
$wshell = New-Object -ComObject Wscript.Shell
$wshell.Popup("This process typically takes about 1 minute.  You will be 
notified when install is complete.",15,"EnterpriseRx - PROD is 
installing...",0x1)

#Wait for application to finish installing:
Wait-Process -name "EnterpriseRx.exe"

返回的错误如下:

代码语言:javascript
复制
Wait-Process : Cannot find a process with the name "EnterpriseRx.exe". 
Verify the process name and call the cmdlet again.
At C:\temp\EnterpriseRx Install TEST\EnterpriseRx Production - Desktop.ps1:9 
char:1
+ Wait-Process -name "EnterpriseRx.exe"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (EnterpriseRx.exe:String) [Wait-
Process], ProcessCommandException
+ FullyQualifiedErrorId : 
NoProcessFoundForGivenName,Microsoft.PowerShell.Commands.WaitProcessCommand

我尝试更改名称以匹配任务管理器中显示的内容,但没有成功;我得到了相同的错误消息。注意:这个进程是一个在命令上运行的进程,我不需要验证它是否正在运行,我知道它正在运行,我只需要知道它运行的是什么。

有什么想法或建议吗?

EN

回答 2

Stack Overflow用户

发布于 2017-06-30 15:46:29

在安装过程中,请使用另一个PowerShell窗口运行以下内容,以了解PowerShell对该进程的看法。

代码语言:javascript
复制
Get-Process | Where-Object {$_.path -match "EnterpriseRx.exe"}

它很可能将进程名简单地看作是"EnterpriseRx“,而没有.exe的结尾。

票数 0
EN

Stack Overflow用户

发布于 2017-06-30 17:03:13

另一种尝试是,通过Start-Process启动进程,因为这个Cmdlet将返回您的进程对象。您可以利用这个来等待:

代码语言:javascript
复制
#Runs EnterpriseRx installer configured for PROD:

$Process = Start-Process .\"EnterpriseRx.exe" -ArgumentList /q, /installType=0, /facilityID=999, /targetEnv=PROD, 
/encryptFacility=0, /S, /D=C:\McKesson\EnterpriseRx, Production -PassThru 

#15 second notification letting user know install is running:
$wshell = New-Object -ComObject Wscript.Shell
$wshell.Popup("This process typically takes about 1 minute.  You will be 
notified when install is complete.",15,"EnterpriseRx - PROD is 
installing...",0x1)

#Wait for application to finish installing:
$Process | Wait-Process
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44849956

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档