首页 > 解决方案 > 通过批处理文件启动 powershell 命令

问题描述

目前正在使用批处理文件。当 .bat 运行时 1. 打开特定的网站页面 2. 在目录中运行 powershell。

当我启动 .bat 时,有什么方法可以在 powershell 中自动输入命令?

这是我目前正在使用的,我想输入命令“node”。

@ECHO OFF
START "C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe" https://stackoverflow.com
START powershell.exe -noexit -command "cd 'C:\Users\[User]\Desktop\File Directory\File in File\File in File in File'"

标签: windowspowershellbatch-file

解决方案


Nevermind, I figured it out. A semicolon allows you to chain commands.

@ECHO OFF
START "C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe"     https://stackoverflow.com
START powershell.exe -noexit -command "cd 'C:\Users\[User]\Desktop\File Directory\File in File\File in File in File'"; "node ."

推荐阅读