for /f "tokens=*" %%a in ('powershell Get-ExecutionPolicy') do (
set originPolicy=%%a
)
通过for循环查找功能来将 powershell 命令的值赋给 batch file 变量

@echo off
set dir=%CD%
set scriptPath=%dir%\example.ps1
for /f "tokens=*" %%a in ('powershell Get-ExecutionPolicy') do (
set originPolicy=%%a
)
powershell Set-ExecutionPolicy 0
powershell %scriptPath%
powershell Set-ExecutionPolicy %originPolicy%

pause

相关文章:

  • 2021-12-04
  • 2021-06-23
  • 2022-01-11
  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
  • 2021-07-18
猜你喜欢
  • 2021-12-04
  • 2021-05-17
  • 2021-09-24
  • 2021-10-20
  • 2021-04-16
  • 2022-12-23
相关资源
相似解决方案