首页 > 解决方案 > 从特定文件夹中的命令行调用提升的 PowerShell 并运行 PowerShell 脚本

问题描述

要创建从特定文件夹运行的批处理文件,批处理应打开提升的 PowerShell(具有管理员权限)并执行 PowerShell 脚本。

从我正在使用的命令行打开提升的 PowerShell:

Start-Process powershell.exe -verb runAs -ArgumentList '-NoExit', '-Command', 'cd c:\temp'

如何从这个 shell 自动运行脚本?我试过了 :

Start-Process powershell.exe -verb runAs -ArgumentList '-NoExit', '-Command', 'cd c:\temp' " &{Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted -file "C:\temp\deploy\install.ps1"  -Verb RunAs}"

标签: powershellbatch-filecmd

解决方案


推荐阅读