PS Context Menu Entry to Run Script as Administrator Without Exiting

  1.    #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 ComputerSystem Spec

  2. Try3's Avatar
    Posts : 2,300
    Windows 10 Home x64 and Pro x86


    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.

      My ComputerSystem Spec


Related Threads
Since I upgraded to Windows 10 Version 1703, I noticed that the Control Panel from Start menu context menu (Windows + X) is missing. I'm sure Microsoft wants to push Settings at all costs, but I wish they didn't try to shove it down users' throats...
Solved delete context menu entry in Customization
Hello every one,cannot delete specific entry 28621 have uninstalled,cleaned registry entries with RevoUninstaller and CCleaner,manually looked for all entries in Registry Editor,used Shellex and Shellview,nothing seems to handle it.Any hints?
A .ps1 script file is a text file that contains one or more Windows PowerShell commands or expressions. A .ps1 file will open with Notepad by default. To run a .ps1 file with PowerShell, you would right click or press and hold on the .ps1 file and...
Hello from Germany. Is it possible to create a new entry in the context menu in "new"? I often need an empty paint-pic. For example: 62745 Thank you.
How to Add 'Run as administrator' to VBS File Context Menu in Windows 10 Some legitimate applications require a full administrator access token (elevated) to perform their functions or tasks. For example, when a program that you are trying to run...
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 21:46.
Find Us