Force Programe to run as Administrator

Tagged: ,

This topic contains 5 replies, has 4 voices, and was last updated by Profile photo of Peter Jurgens Peter Jurgens 7 months, 2 weeks ago.

  • Author
    Posts
  • #59611
    Profile photo of Karem Ali
    Karem Ali
    Participant

    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
    Profile photo of Christian Sandfeld
    Christian Sandfeld
    Participant

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

    • #59656
      Profile photo of Karem Ali
      Karem Ali
      Participant

      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
    Profile photo of Mark Prior
    Mark Prior
    Participant

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

    • #59659
      Profile photo of Karem Ali
      Karem Ali
      Participant

      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
    Profile photo of Peter Jurgens
    Peter Jurgens
    Participant

    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.