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!!!
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0"
processorArchitecture="X86"
name="EXENAME"
type="win32"/>
<description>elevate execution level</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
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?
Thanks!
Warren
Re: Marking your exe for Request to Run as Administrator in Vista
I answered that in your thread. ;)
Re: Marking your exe for Request to Run as Administrator in Vista
Re: Marking your exe for Request to Run as Administrator in Vista
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
Quote:
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
Ok, I mis-read. I thought he had given the steps to digitally sign the app. That's my next goal...
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.
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...
1 Attachment(s)
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... :D
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!
Re: Marking your exe for Request to Run as Administrator in Vista
here is a link to some other information i found yesterday
http://msdn.microsoft.com/msdnmag/is...C/default.aspx
though much of it is covered by randems and robdogs work
Re: Marking your exe for Request to Run as Administrator in Vista
Yes, that link is the one I posted before in some Vista threads months ago and is the one that Hasanni refers to. Its good
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...:cool:
Re: Marking your exe for Request to Run as Administrator in Vista
Yes, its actually very bad design and a security risk to have an entire app running under the admin credientials.
There are things you can do to remove any issues that may require Admin rights.
Re: Marking your exe for Request to Run as Administrator in Vista
I have a silly question...
the marker EXENAME in the XML script has to be
"appname"
OR
"appname.exe"
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.
Re: Marking your exe for Request to Run as Administrator in Vista
I can't seem to get this to work.
Should it be name="filename"
or
name="filename.exe"
I tried both, neither work. The original exe was not written in VB, does that matter?
Re: Marking your exe for Request to Run as Administrator in Vista
In my signature below is a link for a Manifest creator I wrote. At that link, posts #1, #2, #53 & #54 have some good info regarding manifests
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?