You need to connect it to the task scheduler so that it starts after a user logs in using a user account that has administrative access to the system with the highest privileges granted to the processes launched by this account.
This is an implementation that is used to automatically start processes with administrator rights when logging in as a regular user.
I used it to run the OpenVPN GUI helper process, which requires elevated privileges to work properly and therefore will not start properly from the registry key.
At the command line, you can create a task from the XML description of what you want to accomplish; therefore, for example, we have this exported from my system that would launch the notepad with the highest privileges when logging in:
<?xml version="1.0" encoding="UTF-16"?> <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"> <RegistrationInfo> <Date>2015-01-27T18:30:34</Date> <Author>Pete</Author> </RegistrationInfo> <Triggers> <LogonTrigger> <StartBoundary>2015-01-27T18:30:00</StartBoundary> <Enabled>true</Enabled> </LogonTrigger> </Triggers> <Principals> <Principal id="Author"> <UserId>CHUMBAWUMBA\Pete</UserId> <LogonType>InteractiveToken</LogonType> <RunLevel>HighestAvailable</RunLevel> </Principal> </Principals> <Settings> <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy> <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries> <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries> <AllowHardTerminate>true</AllowHardTerminate> <StartWhenAvailable>false</StartWhenAvailable> <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable> <IdleSettings> <StopOnIdleEnd>true</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> </Settings> <Actions Context="Author"> <Exec> <Command>"c:\windows\system32\notepad.exe"</Command> </Exec> </Actions> </Task>
and it is registered on the admin command line using:
schtasks /create /tn "start notepad on login" /xml startnotepad.xml
this answer really needs to be ported to one of the other stackexchange sites, as it is not actually a programming issue per se.
Petesh Mar 25 2018-11-11T00: 00Z
source share