Force Programe to run as Administrator

This topic contains 5 replies, has 4 voices, and was last updated by  Peter Jurgens 1 year, 6 months ago.

  • Author
  • #59611

    Karem Ali

    I am Creating a GUI Application in PowerShell

    But i am Dealing with Group Policy so All Hives in HKLM Needs Admin Privillige

    i wrote a code that error is shown when the App is not running as Admin

    But i want it when a user double click it even he didn't click on " Run As Admin " That UAC Appears and Ask him to

    run it as Admin , so i don't bother Users with Error Appears asking him to run as Admin

    so what should i do ?

    Thanks in Advance ,

  • #59640

    Christian Sandfeld

    I have not tested this myself, but have a look at the Re-launch Powershell Script Elevated Script Center script

    • #59656

      Karem Ali

      i reed it but as i know it will run just if the User Run Ps1 Script Because it depending on "$MyInvocation.ScriptName "
      i think it will not work if it converted to Exe But i will Try and i Hope It works
      i wrote the above but before click submit i trtied to use the Script and it didn't work even with Ps1

      Thank You Christian Sandfeld for your Answer

  • #59647

    Mark Prior

    if you use Sapien Studio, when you build the program you can set it with an elevated manifest

    • #59659

      Karem Ali

      First Thank you Mark Prior for your Answer

      But i am not Using Sapien yet , but i will as you recommanded in my other question

      But if it is no a GUI Script what should i do , I Know i can Take The Code From Sapien but i don't have it right now

      So Can you Tell Me How To do that

      By The Way i am going to Convert Ps1 into Exe to Be Easy for The USer

  • #59668

    Peter Jurgens

    My approach to something similar is to create a shortcut to launch the script/application. Then in the shortcut properties you can set it to always launch elevated.

You must be logged in to reply to this topic.