浅谈C#调用iisapp.vbs

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

创新互联是一家专业提供庆安企业网站建设,专注与网站设计制作、做网站、H5建站、小程序制作等业务。10年已为庆安众多企业、政府机构等服务。创新互联专业的建站公司优惠进行中。

C#调用iisapp.vbs代码:

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

当前文章:浅谈C#调用iisapp.vbs
文章URL:http://www.hantingmc.com/qtweb/news14/543214.html

网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联