如何从powershell脚本中调用cmd批处理

Han*_*ans 2 windows powershell cmd

我有

C:\文件夹\ tail.exe

C:\日志\ LOGFILE.LOG

C:\脚本\ shellscript.ps1

如何从C:\ script\shellscript.ps1中运行C:\ folder\tail.exe

我需要在C:\ script\shellscript.ps1中运行"C:\ folder\tailf.exe C:\ logs\logfile.log",但不依赖于单独的批处理文件,我需要直接调用它.

通常我这样做:cd C:\ folder \然后是tailf.exe C:\ logs\logfile.log

在C:\ script\shellscript.ps1里面我试过了

start-process C:\fetchmail\tail.exe -argumentlist "C:\fetchmail\logs\fetchmail.log"
Run Code Online (Sandbox Code Playgroud)

我可以看到一个窗口闪烁,但不知道它是否有效,窗口应保持打开状态.

man*_*lds 7

你可以做你通常做的事情:

C:\folder\tail.exe c:\logs\logfile.log
Run Code Online (Sandbox Code Playgroud)

请注意,如果路径中包含空格,则必须执行以下操作:

& "C:\fol der\tail.exe" "c:\log s\logfile.log"
Run Code Online (Sandbox Code Playgroud)