1

我试图在 MSDeploy 命令的 preSync 调用期间调用 powershell,但 powershell 在调用后不会退出该进程。命令(来自命令行):“tools/MSDeploy/msdeploy.exe” -verb:sync -preSync:runCommand="powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command C:/MyInstallPath/deploy.ps1 Set -WebAppOffline Uninstall-Service ",waitInterval=60000 -usechecksum -source:dirPath="build/for-deployment" -dest:wmsvc=BLUEPRINT-X86,username=deployer,password=deployer,dirPath=C:/MyInstallPath

我在这里使用了一个hack(http://therightstuff.de/2010/02/06/How-We-Practice-Continuous-Integration-And-Deployment-With-MSDeploy.aspx),它获取了powershell进程并杀死了它,但是没用。我还尝试了 taskkill 和 sysinternals 等效项,但没有任何东西会终止该进程,以便 MSDeploy 出错。该命令已执行,但随后就坐在那里。任何想法可能导致powershell像这样挂起?我在网上发现了一些其他类似的问题,但没有答案。

环境是Win 2K3,使用Powershell 2.0。

更新:这是我现在用来调用我的 powershell 命令的 .vbs 脚本。使用 'cscript.exe path/to/script.vbs' 调用:

Option Explicit
Dim oShell, appCmd,oShellExec
Set oShell = CreateObject("WScript.Shell")
appCmd = "powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ""&{ . c:/development/materialstesting/deploy/web/deploy.ps1; Set-WebAppOffline }"" "
Set oShellExec = oShell.Exec(appCmd)
oShellExec.StdIn.Close()
4

3 回答 3

5

以防万一有人正在为批处理文件寻找类似的解决方案:看看这里 http://epeleg.blogspot.com/2010/06/solution-to-powershell-never-exists.html

小故事:使用 <NUL

于 2010-06-07T07:28:42.683 回答
3

查看此站点上建议的解决方案。PowerShell.exe 似乎不想在像这样执行时退出,直到它的标准输入被调用进程关闭。

于 2010-05-13T05:22:31.830 回答
0

您是否尝试过使用此命令?停止进程 $pid 。$pid 是当前 pid 的内置 powershell 变量。我有这个在服务器 2008 R2 服务器上工作,用于 codecampserver 项目。您可以在此处查看运行它的构建:http: //build-oss.headspringlabs.com。我注意到从预同步中尝试过这个,但我认为这不会影响远程会话。

于 2010-05-10T13:19:01.303 回答