Results 1 to 20 of 20

Thread: Marking your exe for Request to Run as Administrator in Vista

  1. #1

    Thread Starter
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    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>
    Last edited by randem; Aug 5th, 2007 at 07:38 PM.

  2. #2
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    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

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Marking your exe for Request to Run as Administrator in Vista

    I answered that in your thread.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Marking your exe for Request to Run as Administrator in Vista

    What thread is that?

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Marking your exe for Request to Run as Administrator in Vista

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    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...

  7. #7

    Thread Starter
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    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...

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    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...

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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...
    Attached Images Attached Images  
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11

    Thread Starter
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    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!
    Last edited by randem; Aug 5th, 2007 at 04:41 PM.

  12. #12
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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
    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

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #14

    Thread Starter
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    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...

  15. #15
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  16. #16
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    355

    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"

  17. #17
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    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

  18. #18
    Lively Member
    Join Date
    Feb 2005
    Posts
    106

    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?
    Mark (Code Monkey)

  19. #19
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  20. #20
    Addicted Member
    Join Date
    Sep 2008
    Posts
    141

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width