应用程序需要保持在地铁之上,因此需要uiAccess
标志。这是应用程序的最新更改。在先前版本中,未设置uiAccess
标志的情况下,我们可以将应用程序设置为使用此计划任务在用户访问时运行:
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2014-04-23T11:31:11.9188616</Date>
<Author>MU15\Utente</Author>
</RegistrationInfo>
<Triggers>
<LogonTrigger>
<Enabled>true</Enabled>
</LogonTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>MU15\Utente</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
<AllowHardTerminate>false</AllowHardTerminate>
<StartWhenAvailable>true</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>false</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
<Priority>7</Priority>
<RestartOnFailure>
<Interval>PT1M</Interval>
<Count>3</Count>
</RestartOnFailure>
</Settings>
<Actions Context="Author">
<Exec>
<Command>"C:\Program Files (x86)\path\to\application.exe"</Command>
</Exec>
</Actions>
</Task>
我们最近添加了以下应用程序清单:
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<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="true" />
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequest permissionSetReference="Custom" />
<PermissionSet ID="Custom" SameSite="site" Unrestricted="true" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
</application>
</compatibility>
</assembly>
计划任务现在失败,错误0x800702e4:请求的操作需要提升。
我们尝试在%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup
中添加快捷方式,但没有成功。
有没有办法运行设置了uiAccess
标志的应用程序?
答案 0 :(得分:2)
问题在于,任务计划程序默认使用CreateProcess
,这对于运行需要提升的清单的流程无效:您需要使用ShellExecuteEx
。
可能还有其他方法可以做到这一点,但是至少其中一个方法(使用任务调度程序)将任务配置为在任务已经运行时停止其他现有实例。
通过GUI:Settings -> "If task is already running (etc.)"
,设置为"Stop the existing instance"
,或者在XML中:
<MultipleInstancesPolicy>StopExisting</MultipleInstancesPolicy>