PS Context Menu Entry to Run Script as Administrator Without Exiting


  1. Posts : 57
    Windows 10
       #1

    PS Context Menu Entry to Run Script as Administrator Without Exiting


    Edit: I figured it out. All you needed to do was add:

    Powershell.exe -WindowStyle Hidden -Command "& {Start-Process powershell.exe -ArgumentList '-nologo -noexit -command ""& {set-location (split-path ''"""%1"""'' -parent) ; & ''"""%1"""''}""' -verb runAs}"

    this line to the registry entry at the key:

    Computer\HKEY_CURRENT_USER\SOFTWARE\Classes\SystemFileAssociations\.ps1\shell\RunasAdministratorNoEx it\command
    Last edited by JohnTravolski; 19 Jul 2018 at 14:38.
      My Computer


  2. Posts : 16,955
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #2

    John,

    This is very interesting. Please would you post the source of this info so I can study it properly.
    [That Registry key, for example, is markedly different to anything I have seen]

    I normally add in commands to avoid exiting new/amended scripts during testing but this seems to be a much better method.

    Denis
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 17:57.
Find Us




Windows 10 Forums