C# 中的 appcmd 代码?
我有一个运行的网络服务是这样的:
var Proc = new Process();
Proc.StartInfo.FileName = CredentialBatFile;
Proc.StartInfo.Arguments = WebSiteName + " " + Apppool_Username
+ " " + Apppool_Password;
Proc.Start();
bat 文件有:
C:\Windows\system32\inetsrv\appcmd.exe set site "%1"
-virtualDirectoryDefaults.userName:%2
-virtualDirectoryDefaults.password:%3
如果我在本地主机(在服务器上)上运行,它可以正常工作。但是,如果我从 Web 服务在服务器上运行它,它就会失败。
我可以用纯C#代码实现与appcmd
相同的功能吗?
编辑
Exception: Unknown error (0xfffffffe) StackTrace: at
System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
I have an web service that run's this:
var Proc = new Process();
Proc.StartInfo.FileName = CredentialBatFile;
Proc.StartInfo.Arguments = WebSiteName + " " + Apppool_Username
+ " " + Apppool_Password;
Proc.Start();
The bat file has:
C:\Windows\system32\inetsrv\appcmd.exe set site "%1"
-virtualDirectoryDefaults.userName:%2
-virtualDirectoryDefaults.password:%3
If I run on localhost (on the server) it works fine. however if I run it on the server from the web service it fails.
Can I achieve the same function as appcmd
in pure C# code?
EDIT
Exception: Unknown error (0xfffffffe) StackTrace: at
System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来你可以。查看此示例代码。
Looks like you can. Check out this example code.
我通过直接从 c# 调用 appcmd 做了类似的事情。将我的案例适应原始问题,代码将是:
I did something similar by calling the appcmd directly from c#. Adapting my case into the original question the code would be: