powershell - 从特定文件夹中的命令行调用提升的 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}"
解决方案
推荐阅读
- python - 在 Heroku 上部署后文件未加载。在 localhost 和 heroku 本地网络上运行良好
- mysql - 数据库连接中断时不释放 FOR UPDATE 锁
- selenium-webdriver - 当我尝试使用 Selenium 启动 chrome 浏览器时,“驱动程序不可执行”
- javascript - 在Javascript中添加元素时的动态div
- wordpress - 有没有办法一次编辑所有优惠券的“使用限制”?
- python - VS Code Python unittest:即使遵循教程也没有发现任何测试
- excel - 1989 年之后使用 DateSerial 时 VBA 调用错误 6 溢出
- eclipse - Codewarrior 的命令行界面停止等待对话框
- ios - 未定义的符号:_OBJC_CLASS_$_XBarChart
- ios - Swift 4 - 对齐 UILabel 视图的两列