简体   繁体   English

服务崩溃时如何以管理员权限运行程序?

[英]How can I run a program with administrator permission when a service crashes?

I have a program in C++ which is running as a service.我在 C++ 中有一个作为服务运行的程序。 I also have a C# code working as a crash handler and when the C++ code crashes, then the C# code should run.我还有一个 C# 代码用作崩溃处理程序,当 C++ 代码崩溃时,应该运行 C# 代码。 The problem here is that the C# code contains some functions (eg start a service) which I need Administrator permission for them.这里的问题是 C# 代码包含一些我需要管理员权限的功能(例如启动服务)。 Otherwise, my crash handler cannot work.否则,我的崩溃处理程序无法工作。

Is there any way that I can assign this permission to this crash handler without interacting with user.有什么方法可以在不与用户交互的情况下将此权限分配给此崩溃处理程序。 Or, shall I get this permission from the user during the installation procedure.或者,我是否应该在安装过程中从用户那里获得此权限。

You can add manifest which will say that this app should run with admin rights:您可以添加清单,说明此应用应以管理员权限运行:

C++ Console Application prompt "Run as Admin" to run as administrator? C++ 控制台应用程序提示“以管理员身份运行”以管理员身份运行?

Also Windows services can restart automatically if crash如果崩溃,Windows 服务也可以自动重启

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM