浅谈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
分享地址:http://bzwzjz.com/article/djscopp.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 网站建设费用 重庆手机网站建设 外贸网站设计方案 网站建设公司 网站制作报价 LED网站设计方案 成都网站制作 成都网站设计 高端网站设计 企业网站设计 盐亭网站设计 教育网站设计方案 成都h5网站建设 专业网站设计 成都网站建设 成都网站建设 成都网站设计 公司网站建设 网站建设方案 营销型网站建设 成都网站设计 成都商城网站制作