簡體   English   中英

'訪問被拒絕' IIS 殺死 windows 進程

[英]'Access is Denied' IIS on killing a windows process

I have created a Web API for installing the latest version of exe using Web API and hosted via IIS Server.

該過程是下載 -> 關閉 -> 通過 CLI 安裝 Exe。

下載過程運行良好。

關閉正在運行的 exe 異常時捕獲“訪問被拒絕”。

以下是我用來關閉正在運行的 exe 的代碼塊。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebGrease;

namespace API.Controllers
{
    public class TestController : ApiController
    {
        public string Get()
        {


            foreach (Process p in Process.GetProcessesByName("APPLICATION NAME"))
            {
                try
                {
                    p.Kill();
                    p.WaitForExit();
                }
                catch (Exception ex)
                {
                    return ex.Message.ToString();
                }
            }

            return "Aborted";
        }

    }
}

在調試相同的代碼塊時工作正常,但在另一台計算機上測試時顯示“訪問被拒絕”。我猜這個問題與 Windows 身份驗證有關。

調試上述代碼將使用當前記錄的 window 帳戶作為運行 WebAPI 的憑據。 但是,當項目托管在 IIS 中時,將使用其他一些內置系統帳戶。 這通常由 IIS 應用程序池標識確定。 在此處輸入圖像描述
盡管授予 IIS 的管理權限對網站安全存在風險,但至少這可以解決您的問題。
如果問題仍然存在,請隨時告訴我。

暫無
暫無

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

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