0
我想改变的是我的IIS运行其他应用程序在我的IIS 7上运行的应用程序的物理路径。我试图通过appcmd.exe来做到这一点。然而,这似乎是不可能的,因为缺少从asp.net应用程序的授权。更改IIS 7应用程序的物理路径编程
这基本上是我想要做的
private static string Execute(string IISAppName, string NewIISPath)
{
var winPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
var appcmdPath = Path.Combine(winPath, "system32", "inetsrv/appcmd.exe");
var arg = "set app /app.name:\"" + IISAppName + "\" /[path='/'].physicalPath:" + NewIISPath;
ProcessStartInfo startInfo = new ProcessStartInfo(appcmdPath, arg)
{
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};
Process process = Process.Start(startInfo);
var textResult = process.StandardOutput.ReadToEnd();
process.WaitForExit();
return textResult;
}
textResult是一个空字符串。
任何想法?