问题描述
我试图离开命令提示符,因为它是一个死胡同,超过了PowerShell(ISE)。我还没有想出如何在PowerShell(ISE)窗口中运行命令行应用程序。每次我使用启动进程一个命令提示符窗口出现(并消失)。我已经看到一些人建议--Wait和-NoNewWindow,但那些对我来说没有为目前为止。
I'm trying to move away from Command Prompt, because it's a dead-end, over to PowerShell (ISE). I haven't figured out how to run command-line applications within the PowerShell (ISE) window. Everytime I use Start-Process a Command Prompt window appears (and disappears). I've seen some people suggest -Wait and -NoNewWindow but those haven't worked for me so far.
Start-Process MyApplication.exe
这将启动命令提示符,运行应用程序并消失。 PowerShell仍然响应。
This starts Command Prompt, runs the application and disappears. PowerShell remains responsive.
Start-Process MyApplication.exe -Wait
这将启动命令提示符,运行应用程序并消失。在命令提示退出之前,PowerShell无响应。
This starts Command Prompt, runs the application and disappears. PowerShell doesn't get responsive until Command Prompt has exited.
Start-Process MyApplication.exe -Wait -NoNewWindow
这会导致以下结果:
Start-Process:
Start-Process : This command cannot be run due to the error: The system can not find the file specified.
推荐答案
此命令不能运行,因为错误:系统找不到指定的文件。 。
在PowerShell中表示当前目录。这是为了确保用户不会被愚弄在由 $ env:Path
环境变量指定的文件夹中运行恶意可执行文件。
.
in PowerShell represents the current directory. This is to ensure that a user is not fooled into running a malicious executable at a folder specified by the $env:Path
environment variable.
从帮助内容:
要运行当前目录中的脚本,请指定完整路径,或者键入一个点(。
To run a script that is in the current directory, specify the full path, or type a dot (.
) to represent the current directory.
例如,要在当前目录中运行 FindDocs.ps1
文件,请键入:
For example, to run the FindDocs.ps1
file in the current directory, type:
.\FindDocs.ps1
这篇关于在PowerShell窗口中运行应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!