Reputation: 85
So, I have an app that needs admin rights to work.
I created an app.manifest
file. It works perfectly.
But now I need to set my program to autostart in Windows, and I am having trouble with this. If my program has an app.manifest
file - program does not load when windows starts, but when I delete the app.manifest
file - it works well.
Here is code from the app.manifest
file:
<?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="update.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>-->
</application>
</compatibility>
</asmv1:assembly>
Thanks for your help.
Upvotes: 4
Views: 3169
Reputation: 4856
It’s not running because when you request admin access, the user needs to authorize it as admin (click the UAC Allow button), if it’s not popping up, there should be something in the icon-tray where the user can load all blocked exe's by clicking through the icon to give admin rights. when you run without the manifest, it is running only because it defaults to running under standard access (non-admin access, basic user level rights) so you're app is running but without being able to make changes to the system or file/path access items that only admin elevated apps can do. Get me?
The question is, how do you get your exe to auto start with admin privileges if it was installed and initially ran with admin elevated privileges during its installation? There seems to be a few answers to this but i am still searching for which one(s) actually work and are reliable. Basically, if it was elevated once, it should continue to be elevated (automatically, without prompting user) when it’s auto-starting (right after reboots) - but it is NOT doing that, and that's the problem. Let me know if you make progress with this.
UPDATE: 2012.11.10:
I have found a solution, using windows task scheduler to programmatically schedule as task (that being, to run an EXE during reboot/startup) & you have the option to run it as an elevated app, and I think you need to be elevated to begin with in order to be able to schedule this elevated auto run entry in the windows task scheduler. Seems weird I know, but MS has allowed for this (and only this) as a way to auto elevate your apps during startup, and they haven't provided another way to do this. So, use appropriate API's to register a Windows Task Schedule which will run your app elevated.
Upvotes: 5