[英]Powershell Won't Exit After Running Cmd.exe
I'm using powershell to我正在使用 powershell 来
cmd.exe
.cmd.exe
启动带有参数的 Access 数据库。 Everything works fine, but the Exit
command doesn't work after using cmd.exe
command to launch the database.一切正常,但使用
cmd.exe
命令启动数据库后Exit
命令不起作用。
If I comment out the cmd.exe
command, then the Exit
command works just fine.如果我注释掉
cmd.exe
命令,那么Exit
命令就可以正常工作。 But if I use the Exit
command, the script stops there and the Exit
command does not work.但是,如果我使用
Exit
命令,脚本会停在那里并且Exit
命令不起作用。 Below is the entire code that I'm talking about.下面是我正在谈论的整个代码。
## Close Microsoft Access
Stop-process -name MSACCESS -Force
## Download updated Access database to local machine
Copy-Item "F:\New_DB\Win7DBDocs\WC_Sys.mdb" -Destination "C:\DB_Docs" -Recurse -Force
## Copy Documents and Spreadsheets to local machine
echo "Overwriting files C:\DB_WPDocs"
Copy-Item -Path "F:\New_DB\DB_WPDocs\*" -Destination "C:\DB_WPDocs" -Recurse -Force
## Launch Microsoft Access with Parameters
cmd.exe /c "C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE" "C:\DB_Docs\WC_Sys.mdb" /WRKGRP "F:\DB_Docs\Secured.mdw"
Exit
cmd.exe
will block until MSACCESS.EXE
exits. cmd.exe
将阻塞,直到MSACCESS.EXE
退出。
To make cmd.exe
launch the program and return immediately, use the start
command:要使
cmd.exe
启动程序并立即返回,请使用start
命令:
cmd.exe /c start "C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE" "C:\DB_Docs\WC_Sys.mdb" /WRKGRP "F:\DB_Docs\Secured.mdw"
... or drop cmd.exe
completely and use the Start-Process
cmdlet instead: ...或完全删除
cmd.exe
并改用Start-Process
cmdlet:
Start-Process "C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE" -ArgumentList "C:\DB_Docs\WC_Sys.mdb", /WRKGRP, "F:\DB_Docs\Secured.mdw"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.