我怎样才能重新开始从C#code运行IIS作为用户谁是管理员? [英] How can I restart IIS from C# code running as a user who is an administrator?

查看:181
本文介绍了我怎样才能重新开始从C#code运行IIS作为用户谁是管理员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常情况下(在Windows 7中),安装程序会询问您是否允许修改系统。作为管理员,我可以给的授权,而无需提供密码。

Typically (in Windows 7), installing a program will ask for permission to modify the system. As an administrator, I can give the authorization without supplying a password.

我想弄清楚如何采取管理员操作(重新启动IIS)从C#code运行作为用户谁是管理员,但不是管理员账户。

I'm trying to figure out how to take an administrator action (restart IIS) from C# code running as a user who is AN administrator, but the not THE "Administrator" account.

推荐答案

要运行过程,提升你可以使用的运行方式的动词。

To run a process as elevated you can use the runas verb.

Process elevated = new Process();
elevated.StartInfo.Verb = "runas";
elevated.StartInfo.FileName = "Whatever.exe";
elevated.Start();

有关重新启动IIS(如前所述)使用IISRESET。

For restarting IIS (as mentioned before) use iisreset.

希望对您有所助益。

这篇关于我怎样才能重新开始从C#code运行IIS作为用户谁是管理员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆