2014-03-27 227 views
0

我有一个Powershell脚本将CSV文件转换为Excel,但是我想创建一个批处理文件来执行Powershell脚本。当我尝试,我得到一个错误信息:批处理文件执行Powershell脚本

error processing aurguments. there is no option with the following name: execution policy. 
Syntax 
powershell_ise.exe[[-File] <listoffiles>][-Help]-[MTA][-Noprofile] 

批处理文件脚本是:

@echo off 
Powershell_ise.exe -executionpolicy remotesigned -File C:\Users\siddhary\Desktop\csv_to_xlsx .ps1 

但是当我打开Powershell_ise.exe,然后从桌面&运行打开脚本,它成功地运行。但是,当我尝试使用批处理文件做到这一点时,我收到了上述错误消息。 请帮忙。

+1

错误似乎很不言自明的。该选项不受支持。 http://technet.microsoft.com/library/hh847883 –

回答

1

错误消息告诉你到底发生了什么问题。 Powershell_ise.exe不接受一个-executionpolicy参数。您可以通过运行验证这一点你自己:

powershell_ise.exe /? 
0

从powershell_ise.exe更改您的来电powershell.exe

@echo off 
Powershell.exe -executionpolicy remotesigned -File C:\Users\siddhary\Desktop\csv_to_xlsx .ps1 

这里的参考使用powershell_ise.exe,这里的powershell.exe

+0

你已经在你的例子中使用了'_ise'版本。 – foxidrive

+0

我修复了我的答案 – ShaneC

相关问题