如何使用C# 获取IIS 运行framework 版本
来源:互联网 发布:js缺少对象什么意思 编辑:程序博客网 时间:2024/06/05 05:54
This is a problem that I encountered in my daily work. I post this question on the CSDN forum, but nobody answers it these day. Because it's an urgent work, I solve it my self.
The solution is
1. Use the "cscript.exe" and "adsutil.vbs" to get the script mapping of the IIS.
2. Use the Csharp language to integrate the "command window operation" into my CSharp app, which return with the runtime version .
Here's the code block ...
//Process configuration
Process myProcess = new Process();
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("cscript.exe", @"c:/Inetpub/AdminScripts/adsutil.vbs get w3svc/ScriptMaps");
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
myProcess.StartInfo = myProcessStartInfo;
//Process work
myProcess.Start();
StreamReader myStreamReader = myProcess.StandardOutput;
string output = myStreamReader.ReadToEnd();
myProcess.WaitForExit();
//String work
//Restruction:
// 1. This can work on 2.0 and 4.0 whose version is length of 10
// 2. Only one runtime is registered, done with aspnet_regiis on IIS.
String runtimePath = String.Empty;
if (output.Contains(@"Microsoft.NET/Framework64"))
{
runtimePath = @"Microsoft.NET/Framework64/";
}
else
{
runtimePath = @"Microsoft.NET/Framework/";
}
int runtimeIndex = output.IndexOf("v", output.IndexOf(runtimePath));
String version = output.Substring(runtimeIndex, 10);
This code is not that perfect. If you have any suggestion. PLS contact with me.
- 如何使用C# 获取IIS 运行framework 版本
- 使用C#获取服务器IIS版本
- 使用C#获取服务器IIS版本
- 使用C#设置IIS站点运行的.Net版本示例
- 使用C#设置IIS站点运行的.Net版本示例
- 使用C#设置IIS站点运行的.Net版本示例
- 使用ADSI获取IIS版本,C#源代码示例
- .Net如何获取iis版本?
- 使用ADSI获取IIS版本
- 如何设置要运行的.NET Framework的版本?
- VC获取IIS版本
- 利用C#创建 IIS 站点并设置.NET Framework版本为ASP.NET 2.0 的方法
- 利用C#创建 IIS 站点并设置.NET Framework版本为ASP.NET 2.0 的方法
- C# Winform程序如何获取运行路径
- 不重启IIS修改dotnet framework版本
- 不重启IIS修改dotnet framework版本
- iis发布问题之Framework 版本
- 使用C#获取Windows版本(源码)
- mapx的数据绑定。
- ASSMBLY LANGUAGE WEBSITE
- DBA日常sql列表
- html代码中如何将浏览器的菜单栏,状态栏,地址栏,工具栏等隐藏
- C#获取项目程序路径的方法
- 如何使用C# 获取IIS 运行framework 版本
- 考完一科,好吧。
- C#委托及委托链的演示
- UML即将过时的13个理由
- 发送邮件 找回密码
- 使用"增强现实"的3D绘图API来增强角色形象的活泼性
- 字符串截串处理
- 【转】ORACLE10G AWR使用和分析
- spring AOP原理