windows - 从 powershell 打开管理员命令提示符

标签 windows powershell scripting powershell-3.0

我想在 power shell 中执行以下步骤:- 步骤 1.) 从 power shell 打开管理命令提示符。 步骤 2.) 在步骤 1 中打开的管理命令提示符下执行一些命令。 步骤 3.) 捕获步骤 2 中执行的命令的输出。 步骤 4.) 关闭在步骤 1 中打开的管理命令提示符。

经过多次谷歌和搜索后,我无法找到实现上述任务所需的确切电源 shell 命令。 请告知以上是否可行,如果可行那么如何实现?

最佳答案

一种可能的方法(用您的命令替换回显测试)

$prog="cmd.exe"
$params=@("/C";"echo test";" >c:\temp\result.txt")
Start-Process -Verb runas $prog $params 
gc c:\temp\result.txt

关于windows - 从 powershell 打开管理员命令提示符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26094230/

相关文章:

windows - 在 Windows 脚本中运行 ffmpeg 以缩小 MP3 文件时删除错误

windows - 快速像素绘图 C++ Windows 窗体

bash - 使用 ./dot-slash 运行 shell 脚本

linux - 循环的 shell 脚本断行?

linux - 使用 grep/sed 仅在文件末尾递归删除尾随空格?

windows - DMD:对链接和构建的误解

c# - 如何在 C# Windows 窗体中取回已打开窗口的焦点

powershell - 创建 PowerShell 自定义对象

powershell - 如何在PowerShell中设置 "jupyter notebook"的别名?

winforms - 是否可以有一个窗口来插入由 powershell 制作的数据?