请问大家,如何修改winPE系统的开机启动项,在开机后winPE系统的命令行窗口下自动输入"powershell",回车,然后自动执行我所添加的powershell脚本呢?


PowerShell交流中心分类: Questions请问大家,如何修改winPE系统的开机启动项,在开机后winPE系统的命令行窗口下自动输入"powershell",回车,然后自动执行我所添加的powershell脚本呢?
0
huiyannian@126.com asked 9 年 ago

    请教各位老师,我要做一个自动化工具,在winPE系统下修改了开机启动命令,我修改以后的开机命令如下:
wpeinit`r`n c:`r`n powershell -command . set-executionpolicy remotesigned; C:\wcstest\scripts\wcsscripts.ps1; ” 。
但是现在开机后执行到
powershell -command . set-executionpolicy remotesigned; C:\wcstest\scripts\wcsscripts.ps1;”
这条语句后会出现红色错误信息如下:File X:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1 cannot be loaded because running scripts is disabled on this system.并且没有进入powershell里面。
  请问这个问题该怎么解决呢?
如果我不修改开机启动命令,正常开机以后我手动输入powershell,然后回车,是可以进入PS开头的powershell环境的。但是仍然会报错:File X:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1 cannot be loaded because running scripts is disabled on this system.
PS:“C:\wcstest\scripts\wcsscripts.ps1”  这个目录下的wcsscripts.ps1文件是我要执行的一个脚本文件。
时间很紧急,在这先谢谢各位!希望大家能给我一个可行的方法!

0 Answers
1
Mooser Lee 管理员 answered 9 年 ago

管理员权限下面运行:
Set-ExecutionPolicy Unrestricted -Force

huiyannian@126.com replied 9 年 ago

非常感谢!用了您的方法,问题已经解决了!谢谢!