使用批处理文件(batch file)执行powershell命令文件
for /f "tokens=*" %%a in ('powershell Get-ExecutionPolicy') do (
set originPolicy=%%a
)
通过for循环查找功能来将 powershell 命令的值赋给 batch file 变量
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
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