VB应用程序-管理员权限 [英] VB Application - Admin privilidges
问题描述
默认情况下是否可以以管理员身份运行.vb应用程序?也许有些代码可以做到?
Is it possible to run .vb application as Administrator by default? Maybe some code that do?
N.A.Malik
N.A.Malik
推荐答案
在应用清单中使用适当的行替换请求的执行级别行.这将使该应用弹出UAC提示,以便用户可以输入用户名和密码,从而使该应用以管理员身份运行.由于默认情况下,没有任何事情可以使应用程序以管理员身份运行 非管理员用户默认情况下不被授予管理员特权,而具有管理员特权的应用程序会向他们授予管理员特权.
Replace the requested execution level line in you app manifest with the appropriate line. That will make the app pop a UAC prompt so a user can enter a user name and password so the app will run as admin. Nothing can make an app run as admin by default since non-admin users are not allowed admin privileges by default which an app with admin privileges gives them.
对于管理员用户,以及以下更改,您可以使用任务计划程序添加任务,以使程序以赋予用户的最高特权运行.然后,对于admin用户程序,将在不启动UAC提示符的情况下以admin身份运行.
For admin user, along with below change, you can use task scheduler to add task such that program runs with highest privileges afforded a user. Then for admin user program will run as admin without launching UAC prompt.
或者应该可以在系统上禁用UAC,所以我想一切都以管理员权限运行,这对我来说似乎很愚蠢.
Or you can disable UAC on a system supposedly so I guess everything runs with admin privileges which seems rather foolish to me.
<?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">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel node will disable file and registry virtualization.
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of all Windows versions that this application is designed to work with.
Windows will automatically select the most compatible environment.-->
<!-- If your application is designed to work with Windows Vista, uncomment the following supportedOS node-->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>-->
<!-- If your application is designed to work with Windows 7, uncomment the following supportedOS node-->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>-->
<!-- If your application is designed to work with Windows 8, uncomment the following supportedOS node-->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>-->
</application>
</compatibility>
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!-- <dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>-->
</asmv1:assembly>
这篇关于VB应用程序-管理员权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!