用bat执行ps1脚本

View Code
1 powershell.exe -command Set-executionpolicy "bypass"
2 powershell.exe -command get-executionpolicy
3 powershell.exe -command "&{%~dp0Uninstall.ps1}"
4 pause

1.Write a script

2.Allow scripts to run

3.Run scripts

不可以用%cd%------->bat启动的目录

而应该用%~dp0------>bat所在的目录

 

 

bat文件就是正常的cmdlet以bat为扩展

如powershell.exe -command ""

就是一个正常的cmdlet

posted @ 2013-05-07 13:25  daishuguang  阅读(1898)  评论(1编辑  收藏  举报