什么是执行具有管理员权限的方法,最简单的方法是什么? [英] What's the simplest way to execute a method with administrator privileges?

查看:185
本文介绍了什么是执行具有管理员权限的方法,最简单的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前只是叫我自己的程序中一个新的过程:

I am currently just calling my own program in a new process with:

MyProcessStartInfo.Verb = "runas";
MyProcessStartInfo.Arguments = "MyFlag";

和当过程开始时我检查的标志。如果它的存在 - 我只是执行的方法和关闭();

And when the process starts I check for the flag. If it's there – I just execute the method and Close();

不过,我宁愿做的东西,如果它可以简单地做更简约。这可能吗?

But I would rather do something more minimalistic if it could be done simply. Is that possible?

编辑:使用Vista和Windows7

Using Vista and Windows7.

推荐答案

您不能提升一个正在运行的进程。它的只是的不可能。你正在做正确的方式,通过产卵另一个进程使用提升priviledges。有没有其他的办法。

You can not elevate a running process. It's simply not possible. You are doing it the correct way, by spawning another process with elevated priviledges. There is no other way.

感谢。但我想也许有一种方式开始新的方法,新的工艺。

Thanks. but I was thinking maybe there is a way to start a method as a new process.

您可以创建一个单独的应用程序的可执行文件,有你在它的方法,那么你就不需要重新启动应用程序。你只需要启动其他程序。

You could create a separate application executable that has your method in it, then you would not need to restart your application. You would only need to start that other process.

这篇关于什么是执行具有管理员权限的方法,最简单的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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