Marking your exe for Request to Run as Administrator in Vista
I have been all over the Internet and there is nothing that explicitly tells you how to mark your file to "Run As Administrator". Everyone uses the buzz words but no one states exactly how to do it, Especially for VB exe's.
I will give you a quick lesson on how it can be done with a little work. Since VB handles resource information differently than other languages such a C++ you can forget about using VB's resource editor on the exe. In my procedure you will need the help of a the program "Resource Hacker" by Angus Johnson http://www.angusj.com/resourcehacker/
The procedure is as follows:
1 - Open the exe in the Resource Hacker
2 - Go to Action->Add a New Resource
3 - Select any text file. it really doesn't matter for you are going to delete the information anyway. So choose a small one...
4 - Use the following entries to fill in the New Resource box
Resource Type - 24
Resource Name - 1
Resource Language - 3081
4 - Select your new resource from the list and Replace whatever is in the language (3081) with a copy the XML script (Below) then compile the script and save back to the original exe. That's It!!!. Your exe is now marked to request to run as administrator on Vista. You will know this worked by the shield that Vista places on your applications icons.
Don't forget to change the marker EXENAME in the XML script to the same name as the exe you are marking or it won't work!!!
Re: Marking your exe for Request to Run as Administrator in Vista
I just did this with one of my VB6 apps and it does exactly what Randem said! Works great and gives it admin rights.
One question - is there any way to keep it from promting you to run it? Right now it says an unidentified program wants to access your computer. If my exe is digitally signed, will it no longer prompt this? Or will it still prompt but just say who the publisher is now?
Re: Marking your exe for Request to Run as Administrator in Vista
This is what he said in the other post. Of course, all this is above me but I assume the xml file routine he mentioned is the same as you are doing here? As far as being able to create a task with an elevated process and security token, thats what I would like to see someone do so you are not prompted before running the exe. But this routine definately helps in many ways.
Warren
As I have noted before, that "faq" I helped with doesnt cover needed areas for this feature. You need to designate with an xml file that the task requires admin rights, but if you dont want a process prompting you for the credientials then you need to create the task with an elevated processand security token. Its a bit complex but...
Re: Marking your exe for Request to Run as Administrator in Vista
I've been working on that lately for both VB 6 and VB.NET but its an involved process and the proper way's documentation is not clear.
I should have my article finished soon, hopeflully lol.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Re: Marking your exe for Request to Run as Administrator in Vista
Isn't that the way... I really haven't found concise documentation from Microsoft on anything concerning Vista (except the fact that they want to cram it down your throat, like it or not). It seems to be all hit and miss...
Re: Marking your exe for Request to Run as Administrator in Vista
Yes, I have found ways to mimic the process but its not the way Vista actually does it. There are ways to do things and there is the correct / stable way to do it.
Preview of my third Vista article...
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Re: Marking your exe for Request to Run as Administrator in Vista
Great!!!!
Like the Russian Comedian Yakov Smirnoff stated:
No, we do not have a dictatorship. We even have two TV channels, Channel A and Channel B. Channel A is Russian propaganda and when you turn to Channel B there's the KGB saying turn back to Channel A!
though much of it is covered by randems and robdogs work
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Re: Marking your exe for Request to Run as Administrator in Vista
@Warren,
Are you sure your app needs Admin Rights (most don't). It's a waste to ask for it and don't really need it, and Vista doesn't ask everytime you want to run your app either...
Re: Marking your exe for Request to Run as Administrator in Vista
I set my manifest as invoker
<?xml version="1.0" encoding="utf-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
Then if the program updater button is clicked a messagebox prompts for Admin.
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
Re: Marking your exe for Request to Run as Administrator in Vista
You know, I have a problem with my application requiring the manifest. It adds a person to a group using active directory. If I don't include the manifest it looks as if everything was successful, but it doesn't really add the person to the group no error msgs or anything, but if I include the manifest it works without a hitch. Anyone know why that would be?