2013-03-26 48 views
1

我想Reserve the portport binding通过编程用下面的代码:无法在Win XP机器上运行netsh命令

private void PortReserve() 
{ 
    try 
    { 
    System.Diagnostics.Process process = new System.Diagnostics.Process(); 
    System.Diagnostics.ProcessStartInfo startInfo = new   
    System.Diagnostics.ProcessStartInfo(); 
    startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; 
    startInfo.FileName = "cmd.exe"; 
    startInfo.UseShellExecute = true; 
    startInfo.Arguments = @"/c netsh http add urlacl url=https://127.0.0.1:8083/ user=EVERYONE"; 
    process.StartInfo = startInfo; 
    process.Start(); 

    } 
    catch (Exception ex) 
    { 
     throw ex; 
    }} 

进行端口绑定: 与@"/c netsh http add sslcert ipport=127.0.0.1:8083 certhash=df03c4b0b32f3302a3b70abe6b5dfd864d0986a5 appid={00112233-4455-6677-8899-CCBBCCDDEEFF} clientcertnegotiation=enable";

以上替换的startInfo.Arguments参数命令在win 7win servers8机器中完美工作,但是当涉及到Win xp它开始在CMD中输入错误: The following command was not found http add urlacl url=https://127.0.0.1:8083 user=Everyone

我检查了所有machinemmc成功导入的证书。

在这种情况下我该怎么办?

回答

4

根据MSDN你不能使用netsh与xp。

如果您运行的是Windows Server 2003或Windows XP,请使用 HttpCfg.exe工具。使用Windows Server 2003安装此工具。 使用Windows XP,您可以在Windows XP Service Pack 2支持工具下载该工具。有关更多信息,请参阅Httpcfg概述。 Windows支持工具文档说明了 Httpcfg.exe工具的语法。