- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
在我的 VB6 应用程序中,我打开其他 EXE 文件。我的应用程序在没有任何 UAC 提示的情况下运行,但我有一个检查软件更新的 EXE。这会提示 UAC 提示符。那么Windows是如何决定是否显示UAC提示的呢?我看到这个 link .那么它是否取决于我在应用程序中编写的代码?有趣的是,我的应用程序(即主 EXE 文件)不提示 UAC,而检查和下载更新的小 EXE 提示 UAC。我对所有 EXE 文件都进行了数字签名。我已经浏览了以下链接:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa511445.aspx
http://technet.microsoft.com/en-us/library/cc505883.aspx和其他一些。
但是我还是不太清楚。
最佳答案
您几乎肯定会遇到 Windows Installer Detection Technology 🕗 兼容性启发式。Windows 将尝试检测应用程序何时是安装程序,并且可能需要提升。
Installer Detection only applies to:
- 32 bit executables
- Applications without a
requestedExecutionLevel
- Interactive processes running as a Standard User with LUA enabled
Before a 32 bit process is created, the following attributes are checked to determine whether it is an installer:
- Filename includes keywords like "install," "setup," "update," etc.
- Keywords in the following Versioning Resource fields: Vendor, Company Name, Product Name, File Description, Original Filename, Internal Name, and Export Name.
- Keywords in the side-by-side manifest embedded in the executable.
- Keywords in specific StringTable entries linked in the executable.
- Key attributes in the RC data linked in the executable.
- Targeted sequences of bytes within the executable.
所以,正如你所说:
but i have a exe which checks for updates to software
我的猜测是这个 CheckForUpdates.exe
正在触发兼容性试探法。
正确的做法是将程序集 list 添加到“正在检查”的可执行文件中,通知 Windows 它应该不提升效用。这是通过 list 中 asInvoker
的 requestedExecutionLevel
完成的:
AssemblyManifest.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="ITReasearchAssociates.Contoso.Updater"
type="win32"
/>
<description>Update checker</description>
<!-- Run as standard user. Disable file and registry virtualization -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
这样您的“检查更新”应用程序将永远不会提升,也永远不会错误地获得管理权限。
如果您希望您的更新程序实际应用更新(需要管理权限的更新),那么您将以管理员身份启动您的更新程序应用程序。
//Check if there are updates available
if (!CheckForUpdatesAvailable())
return; //no updates. We're done
//If the user is an administrator, then get the update
if (IsUserAnAdmin())
{
//Maybe throw in a "Hey, user, wanna get the update now?" dialog
DownloadAndApplyUpdates();
return;
}
//The user is not an admin.
//Relaunch ourselves as administrator so we can download the update
//Maybe throw in a "Hey, user, wanna get the update now?" dialog. A button with a UAC shield on it
ExecuteAsAdmin(Application.ExecutablePath, "/downloadUpdate");
辅助函数:
private Boolean IsUserAnAdmin()
{
//Public domain: no attribution required
//A user can be a member of the Administrator group, and yet not be an administrator.
//Conversely, the user can be an administrator while not being a member of the administrators group.
var identity = WindowsIdentity.GetCurrent();
return (null != identity && new WindowsPrincipal(identity).IsInRole(WindowsBuiltInRole.Administrator));
}
private void ExecuteAsAdmin(string Filename, string Arguments)
{
//Public domain: no attribution required
ProcessStartInfo startInfo = new ProcessStartInfo(Filename, Arguments);
startInfo.Verb = "runas";
System.Diagnostics.Process.Start(startInfo);
}
然后在启动时,您只需查找 /downloadUpdate
命令行参数即可知道您的工作是实际上做工作:
public Form1()
{
InitializeComponent();
//Ideally this would be in program.cs, before the call to Application.Run()
//But that would require me to refactor code out of the Form file, which is overkill for a demo
if (FindCmdLineSwitch("downloadUpdate", true))
{
DownloadAndApplyUpdates();
Environment.Exit(0);
}
}
Note: Any code is released into the public domain. No attribution required.
关于windows - Windows如何决定是否显示UAC提示符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20096706/
我在使用 UAC 时遇到问题,并以其他用户身份执行非交互式进程(API,例如 CreateProcessAsUser 或 CreateProcessWithLogonW)。 我的程序旨在执行以下操作:
我有一个 VB6 应用程序,我已经销售了 12 年多。有时我的用户很难让应用程序运行。数据写入将进入/My Documents,因此除了安装文件(EXE 等)之外什么都没有进入 C:\Program
我见过几个与此相反的问题; “如何禁用虚拟化?”那不是我的问题。我想强制应用程序运行虚拟化 启用 . 我有一个在 Windows XP 下运行良好的应用程序,但是,因为它将其配置写入其工作目录(“C:
我有一个应用程序需要管理员权限才能执行某些操作。我只想在启动时显示 UAC 提示,然后提升。我不确定该怎么做,但我听说过诸如 list 之类的东西,但在任何地方都看不到明确的答案。 最佳答案 您需要一
我真的不明白Windows UAC ... 我需要我的程序能够更新文件并将文件添加到属于程序的特定目录。该目录可能是 Program Files 中应用程序的子目录,例如 c:\Program Fil
我一直在互联网上寻找答案,但似乎没有直接回答,所以我想我会问。 案例场景:我想截取当前在计算机屏幕上的内容。如果是 Windows 登录屏幕,我希望它是那样。如果它是事件用户的桌面,我想成为那个。如果
我希望这是我关于这个 SIP 主题的最后一个问题,我已经设法克服了最后一个 issue我曾通过请一位 friend 从远程计算机帮助我,我能够在计算机之间进行连接,但根据所有 examples 的说法
我有一个BHO,可以将网页捕获为图像,然后运行另一个过程pngcrush如此创建的图像。我在启用UAC的系统中面临的问题是,每次IE运行时,我都会收到关于从BHO生成的pngcrushing进程的警告
我的产品需要更改文件关联。为了允许它在 Vista 中以非管理员身份运行,我已将注册表更改代码移动到名为“assocsetup.exe”的单独二进制文件中。 启动时,Vista UAC 会正确请求以管
我使用 WiX 3.6 构建了一个 Windows Installer 程序包,其中嵌入了自定义托管 (C#) 操作。 在此阶段,安装要求 使用特定的本地管理员帐户(在本例中为 SharePoint
我的应用程序由服务器和客户端界面组成。我希望客户端能够请求服务器写入注册表项。现在我对 java 库进行了研究,发现了一些库。问题出在管理员权限上。当我运行一个简单的 java 程序从注册表中读取数据
我正在为我的应用程序制作一个安装程序,它在 xp 上工作正常,但在 vista 上,UAC 会出现问题,除非我以管理员身份运行,安装后运行我的应用程序时会出现意外错误,知道吗?我正在将应用程序安装在
我在 Vista/7 上遇到 UAC 问题。我的 UAC 执行级别 = requireAdministrator 的安装程序安装并运行我的应用程序。应用程序 UAC 执行级别 = asInvoker。
我已经使用 Verisign 签署了我的应用程序,将所有注册表变量存储在 HKCU 中以避免请求管理员权限,但 UAC 命令仍然提示用户他/她是否希望以下内容对其计算机进行更改。我该如何防止这种情况发
首先,我想强调的是,我并不是想做任何“下流”或“骇人听闻”的事情,也不是想对用户隐瞒任何事情。 在我的应用程序安装(使用 InstallShield LE)期间,Windows UAC 提示用户允许它
我有一个没有资源的应用程序(根本没有,所以也没有 UAC list )。此应用程序使用 CopyFile 将自身安装到 appdata/roaming 文件夹。它还设置了自动启动,因此它会在每次启动时
我已经阅读了几个关于 UAC 和特权提升的问题,但没有找到令人满意/全面的答案。 我有这种情况:在 Windows 6 或更高版本上,当用户打开配置窗口时,我必须在确定按钮上显示盾牌(BCM_SETS
我有一个类库,它在注册表 (HKLM\Software\XXX) 中保存系统范围的配置数据。该库用于各种 Windows 版本(XP、2003、7、2008 R2)上的各种应用程序(服务、Window
显示 UAC 提升提示时是否触发了任何窗口事件?我看过 SwitchDesktop,但看不到任何关于如何接收通知的提及。 我的 direct show 应用程序表现不佳,我希望能够在显示提示时暂停图表
我有兴趣在临时 session 中启动一个窗口,例如 UAC 提示的显示方式。一些人对这个概念有些兴趣,所以我想我应该在这里问一下。本质上,我们想要的是一个提升的窗口,例如 UAC“您确定要”提示,但
我是一名优秀的程序员,十分优秀!