簡體   English   中英

批處理文件以執行Powershell腳本

[英]Batch file to execute a Powershell script

我有一個Powershell腳本,可以將CSV文件轉換為Excel,但是我想創建一個批處理文件來執行該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 ,然后從桌面打開該腳本並運行時,它將成功運行。 但是,當我嘗試使用批處理文件執行此操作時,會收到上述錯誤消息。 請幫忙。

錯誤消息告訴您確切的問題。 Powershell_ise.exe不接受-executionpolicy參數。 您可以運行以下命令自行驗證:

powershell_ise.exe /?

將您的呼叫從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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM