浅谈C#调用iisapp.vbs

开发 后端
这里介绍目前的方法就是C#调用iisapp.vbs获取。今天准备在我的文本转换工具里集成这个功能,于是,实现C#调用iisapp.vbs。

自从用了ASP.NET2.0以后,这个问题被渐渐关注起来,目前的方法就是C#调用iisapp.vbs获取。今天准备在我的文本转换工具里集成这个功能,于是,实现C#调用iisapp.vbs。

C#调用iisapp.vbs代码:

  1. usingSystem;  
  2. usingSystem.Text;  
  3. usingSystem.Text.RegularExpressions;  
  4. usingSystem.Diagnostics;  
  5. usingSystem.Management;  
  6. usingSystem.Windows.Forms;  
  7.  
  8. namespaceTextConvertor  
  9. {  
  10. /**////<summary> 
  11. ///W3wp的摘要说明。  
  12. ///</summary> 
  13. publicclassW3wp  
  14. {  
  15. privateW3wp(){}  
  16. publicstaticstringGetAllW3wp(stringinput)  
  17. {  
  18. ObjectQueryoQuery=newObjectQuery
    ("select*fromWin32_ProcesswhereName='w3wp.exe'");  
  19. ManagementObjectSearcheroSearcher=newManagementObjectSearcher(oQuery);  
  20. ManagementObjectCollectionoReturnCollection=oSearcher.Get();  
  21.  
  22. stringpid;  
  23. stringcmdLine;  
  24. StringBuildersb=newStringBuilder();  
  25. foreach(ManagementObjectoReturninoReturnCollection)  
  26. {  
  27. pid=oReturn.GetPropertyValue("ProcessId").ToString();  
  28. cmdLine=(string)oReturn.GetPropertyValue("CommandLine");  
  29.  
  30. stringpattern="-ap\"(.*)\"";  
  31. Regexregex=newRegex(pattern,RegexOptions.IgnoreCase);  
  32. Matchmatch=regex.Match(cmdLine);  
  33. stringappPoolName=match.Groups[1].ToString();  
  34. sb.AppendFormat("W3WP.exePID:{0}AppPoolId:{1}\r\n",pid,appPoolName);  
  35. }  
  36.  
  37. returnsb.ToString();  
  38. }  
  39. }  

【编辑推荐】

  1. 如何用C#和ADO.NET访问
  2. 浅析C# Switch语句
  3. C#验证输入方法详解
  4. 简单介绍C# 匿名方法
  5. C# FileSystemWatcher对象
责任编辑:佚名 来源: MSDN社区
相关推荐

2009-09-02 16:36:37

C#调用Excel对象

2009-08-28 15:58:54

C#窗体里调用

2011-04-08 09:52:44

C++C#DLL

2009-08-21 11:02:55

C#异步调用

2009-08-20 19:08:30

C#异步调用

2011-09-21 10:56:31

C#结构

2009-08-20 18:30:33

C# ReaderWr

2009-08-19 17:12:18

C# Connecti

2009-08-12 11:24:25

C# String对象

2009-08-07 11:26:53

C#数组结构

2009-08-31 09:37:09

C# Employee

2009-08-26 13:15:38

C#选择控制

2009-08-26 15:46:01

C#匿名类型

2009-08-14 17:58:05

C#接口方法

2009-08-25 16:16:43

C# oledbcon

2009-09-02 15:41:21

C# HTTPWebR

2009-08-20 10:24:52

C#开发WinForm

2009-08-06 15:30:23

C#类型系统

2009-08-17 16:18:47

C#调用CreateO

2009-08-10 10:04:25

C#抽象类C#接口
点赞
收藏

51CTO技术栈公众号