我是窗口服务谁与SQL服务器进行通信,在某些情况下,SQL Server服务停止,所以我声明我自己的应用服务器,它通过这个代码如何启动Windows服务作为管理员权限
ServiceController sc = new ServiceController("MSSQL$SQLEXPRESS");
sc.Start();
sc.WaitForStatus(ServiceControllerStatus.Running);
但它需要管理员权限启动服务如何开始我的窗口服务为管理员
我是窗口服务谁与SQL服务器进行通信,在某些情况下,SQL Server服务停止,所以我声明我自己的应用服务器,它通过这个代码如何启动Windows服务作为管理员权限
ServiceController sc = new ServiceController("MSSQL$SQLEXPRESS");
sc.Start();
sc.WaitForStatus(ServiceControllerStatus.Running);
但它需要管理员权限启动服务如何开始我的窗口服务为管理员
我只是在我的app.manifest文件中添加此标记 <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
它的工作原理...
让分裂到一切步骤
所有信息文件可以根据你的情况是有点不同。 More info
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequest permissionSetReference="Custom" />
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
</applicationRequestMinimum>
</security>
</trustInfo>
</asmv1:assembly>
您是否尝试过运行的启动服务为管理员应用程序? – Alioza
但这两个应用程序都是windows服务。我如何以管理员身份运行我的Windows服务。 –
我只是在我的app.manifest文件中添加了这个标签 它能正常工作... –