Force Programe to run as Administrator

Welcome Forums General PowerShell Q&A Force Programe to run as Administrator

This topic contains 5 replies, has 4 voices, and was last updated by

 
Participant
2 years, 3 months ago.

  • Author
    Posts
  • #59611

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 75
    Rank: Member

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

    • #59656

      Participant
      Points: 0
      Rank: Member

      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

    Participant
    Points: 42
    Rank: Member

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

    • #59659

      Participant
      Points: 0
      Rank: Member

      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

    Participant
    Points: 62
    Rank: Member

    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.

The topic ‘Force Programe to run as Administrator’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort