• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

先生使用ASP.NET编程通过我的系统获取特定机器的所有系统服务状态

用户头像
it1352
帮助1

问题说明

使用以下代码的SIR我得到我的系统所有服务状态但我想看到其他机器服务状态所以请给我解决方案。



thanx



我尝试过:



使用System.Collections.Generic;

使用System.Linq;

使用System.Web;

使用System.Web.UI;

使用System.Web .UI.WebControls;

使用System.ServiceProcess;





命名空间Myservice

{

public partial class _Default:System.Web.UI.Page

{

protected void Page_Load(object sender,EventArgs e)

{

ServiceController [] services = ServiceController.GetServices(SMART);

Response.Write(运行服务列表:< br>);

foreach(服务中的ServiceController服务)

{

Response.Write( string.Format(服务名称:{0},状态{1}
,service.ServiceName,service.Status.ToString()));

}

}

}

}

SIR using following code i get my system all services status but i want to see other machine services status so please give me solution.

thanx

What I have tried:

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ServiceProcess;


namespace Myservice
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ServiceController[] services = ServiceController.GetServices("SMART");
Response.Write("List of running services :
");
foreach (ServiceController service in services)
{
Response.Write(string.Format(" Service Name: {0} , status {1}
", service.ServiceName, service.Status.ToString()));
}
}
}
}

正确答案

#1
您可以使用代码执行此操作你有。您需要牢记安全性,运行asp.net代码的帐户需要对目标计算机的适当访问权限,如果它是内置的匿名帐户,则无法访问其他计算机,因此您需要我需要更改代码运行的帐户(谷歌有关如何配置该代码的示例)。



请注意,您也无法访问在机器上运行的服务客户端浏览器,如果这是你最终想要做的事情。
You do it using the code you have. You need to bear in mind the security though, the account the asp.net code is running under needs appropriate access to the target machine and if it is the built-in anonymous account it won't be able to access other machines so you'll need to change the account the code runs under (谷歌 for examples on how you can configure that).

Note also you can't access services running on the machine of the client browser if that is what you're ultimately trying to do.

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcfckge
系列文章
更多 icon
同类精品
更多 icon
继续加载