我的应用程序使用ClickOnce技术。今天,我需要作为管理员运行它。我修改了清单文件
<requestedExecutionLevel level="asInvoker" uiAccess="false" />至
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />但是VS无法编译该项目:
错误35 ClickOnce不支持请求执行级别的“需求管理员”。
我认为不可能立刻使用它们。难到不是么?我需要更改系统时间,我可以在应用程序级别这样做吗?我能效法它吗,所以应用。能做我想做的事。我改变时间+2小时,然后放回去一秒钟。我有几个替罪羊,他们要求时间。
发布于 2011-04-27 04:13:27
时间是一件全系统的事情,你不能仅仅为了你的过程而改变它。对依赖项撒谎的唯一方法是使用Detours或其他类似的方法来挂钩API。不允许如果你是一个低用户帐户。
修改时间需要“更改系统时间”和/或“更改时区”特权(通常授予管理员帐户)。
正如@Chris所提到的,admin和ClickOnce是不兼容的。
发布于 2013-10-04 12:18:26
实际上,您不能以管理权限运行ClickOnce应用程序,但是有一些小问题,您可以使用管理员权限启动新进程。在App_Startup中:
if (!IsRunAsAdministrator())
{
var processInfo = new ProcessStartInfo(Assembly.GetExecutingAssembly().CodeBase);
// The following properties run the new process as administrator
processInfo.UseShellExecute = true;
processInfo.Verb = "runas";
// Start the new process
try
{
Process.Start(processInfo);
}
catch (Exception)
{
// The user did not allow the application to run as administrator
MessageBox.Show("Sorry, this application must be run as Administrator.");
}
// Shut down the current process
Application.Current.Shutdown();
}
private bool IsRunAsAdministrator()
{
var wi = WindowsIdentity.GetCurrent();
var wp = new WindowsPrincipal(wi);
return wp.IsInRole(WindowsBuiltInRole.Administrator);
}阅读整篇文章。
但是,如果您想要更多的本地和更简单的解决方案,只需要求用户以管理员身份运行Internet,ClickOnce工具也将具有管理权限。
发布于 2011-04-27 03:18:07
正确- ClickOnce不能带有管理员权限的运算符。事实上,它的目的是不。
https://stackoverflow.com/questions/5713825
复制相似问题