[英]Unable to run the ASP.NET Core Web API project in IIS Express
[英]Unable to run powershell script in IIS hosted .net web api project
I am trying to run a powershell
script(script is used to updated a excel sheet data) in .net web api
project as mantioned bellow,
var ps1File = @"C:\ActiveLKTel.ps1";
var startInfo = new ProcessStartInfo()
{
FileName = "powershell.exe",
Arguments = $"-NoProfile -ExecutionPolicy unrestricted \"{ps1File}\"",
UseShellExecute = false
};
Process.Start(startInfo);
This works fine when I run .net web api
project in localhost, but this does not work when I deploy the .net web api
project in IIS
有人能告诉我如何解决这个问题吗?
您应该使用-File
参数。
var ps1File = @"C:\ActiveLKTel.ps1";
var startInfo = new ProcessStartInfo()
{
FileName = "powershell.exe",
Arguments = $"-NoProfile -ExecutionPolicy unrestricted -File \"{ps1File}\"",
UseShellExecute = false
};
Process.Start(startInfo);
当您在 IIS 中运行脚本时,它不起作用,因为该脚本将在 IIS 应用程序池上的用户上下文中运行。 此帐户是否有权:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.