2014-03-27 68 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

相關問題