Windows 10: PS Context Menu Entry to Run Script as Administrator Without Exiting

Discus and support PS Context Menu Entry to Run Script as Administrator Without Exiting in Windows 10 Support to solve the problem; I'm really close on this one. Basically, I want to create a context menu entry for .ps1 files that run the script as administrator without exiting the... Discussion in 'Windows 10 Support' started by JohnTravolski, Jul 18, 2018.

  1. PS Context Menu Entry to Run Script as Administrator Without Exiting


    I'm really close on this one. Basically, I want to create a context menu entry for .ps1 files that run the script as administrator without exiting the console window after running. So I can create the key:
    Code: Computer\HKEY_CURRENT_USER\SOFTWARE\Classes\SystemFileAssociations\.ps1\shell\RunasAdministratorNoExit[/quote] with the values:

    PS Context Menu Entry to Run Script as Administrator Without Exiting UkeWJ.png

    and that's all fine and dandy to create the entry. However, in order to actually make it do something, I need to add another key, the command key:
    Code: Computer\HKEY_CURRENT_USER\SOFTWARE\Classes\SystemFileAssociations\.ps1\shell\RunasAdministratorNoExit\command[/quote] And in this key, I have something that almost works, but not quite. So the default value of the above command key is:
    Code: Powershell.exe -WindowStyle Hidden -Command "& {Start-Process PowerShell.exe -Verb RunAs -ArgumentList '-NoLogo -NoExit -File """%1"""'}"[/quote] But there's one big problem with this method; when the script finishes, it returns me to the "C:\Windows\system32" directory instead of the directory of the script itself. See my image below for clarification:

    PS Context Menu Entry to Run Script as Administrator Without Exiting LX42k.png


    Further, when I use the context menu entry I created to run scripts containing lines such as:
    Code: $settingsfiles = Get-ChildItem -Recurse $scanPath[/quote] Instead of it recursing through all the folders local to the script I just ran, it tries to recurse through all the folders at "C:\Windows\system32!" Clearly this is undesired. So here's my question:
    What do I need to change in the default value of the command key in order to get the PowerShell script to act as if it was run from the same directory as the script?

    :)
     
    JohnTravolski, Jul 18, 2018
    #1

  2. Custom context menu entries

    So, just throwing this out there, in case somone knows.

    I have added a custom context menu entry for the program rightload, since by default the menu is broken in vistax64.

    It works pefect with single files, but when I select mutiple files and try to open, I get mutiple instances of the program (which makes sense), here is my entry:

    C:\Program Files (x86)\Rightload\Rightload.exe --server=1 --autostart %1

    So the %1 passes the filename to the program, and when I select multiple files it is just opening multiple instances of rightload each with a different file.

    What I'd like to do is be able to pass a list of the files selected to the program. Since I know it is capable of uploading multiple files from the context menu, all in one instance.

    So, is there something I can pass besides %1 that will do this? I have looked around and can't seem to find an answer anywhere... *Frown PS Context Menu Entry to Run Script as Administrator Without Exiting :(
     
    ArmoredCavalry, Jul 18, 2018
    #2
  3. Necrofire Win User
    CCC Context menu

    I was recently greeted to a new entry in my desktop context menu after installing 8.12 drivers with the Catalyst Control Center:


    PS Context Menu Entry to Run Script as Administrator Without Exiting ati2.png


    I have no idea what the second entry does, since clicking it results in nothing happening.
    So I open up CCC and find this new section:


    PS Context Menu Entry to Run Script as Administrator Without Exiting ati1.png


    It's completely disabled. I only have a single HD3850. The IGP on my mobo is nVidia, which is disabled anyway.

    I spent the last hour or so finding a way to remove the second entry, and this is the only thing I could find:
    Deleting this key removes both entries from the context menu
    Code: KEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers\ACE[/quote] This solved one problem and caused another. I do not like the tray icon, so I have it disabled, so the only way I know to get into CCC is via the context menu. Does anyone know of a way to disable just the "Configure Additive Graphics" entry and keep the CCC entry?

    If I kept both disabled, is there some sort of shortcut I could make to get there instead? I don't want to have to go to Display->Settings->Advanced->CCC every time.
    EDIT: Just made a hotkey to get there. *Smile PS Context Menu Entry to Run Script as Administrator Without Exiting :)
     
    Necrofire, Jul 18, 2018
    #3
  4. PS Context Menu Entry to Run Script as Administrator Without Exiting

    How to get rid of old context menus?

    I was going to suggest editing teh registry , but....
     
    francis511, Jul 18, 2018
    #4
Thema:

PS Context Menu Entry to Run Script as Administrator Without Exiting

Loading...
  1. PS Context Menu Entry to Run Script as Administrator Without Exiting - Similar Threads - Context Menu Entry

  2. All the entries in the "New menu" in Windows context menu are missing

    in Windows 10 Gaming
    All the entries in the "New menu" in Windows context menu are missing: Suddenly, all the entries from my "New" context menu disappeared, I don't know why. I've tried restoring the defaults, enabling, disabling new entries, nothing helped, no entries in the menu. How to restore it?...
  3. All the entries in the "New menu" in Windows context menu are missing

    in Windows 10 Software and Apps
    All the entries in the "New menu" in Windows context menu are missing: Suddenly, all the entries from my "New" context menu disappeared, I don't know why. I've tried restoring the defaults, enabling, disabling new entries, nothing helped, no entries in the menu. How to restore it?...
  4. All the entries in the "New menu" in Windows context menu are missing

    in Windows 10 BSOD Crashes and Debugging
    All the entries in the "New menu" in Windows context menu are missing: Suddenly, all the entries from my "New" context menu disappeared, I don't know why. I've tried restoring the defaults, enabling, disabling new entries, nothing helped, no entries in the menu. How to restore it?...
  5. All files have "Run as administrator" right-click menu entry

    in Windows 10 Network and Sharing
    All files have "Run as administrator" right-click menu entry: Hello, I have updated my PC to 21H, there's now "run as administrator" right-click menu entry on every file. i don't want this. Is there any way to remove this entry, and leave it only for executables?...
  6. Run PowerShell Script As An Administrator

    in Windows 10 Support
    Run PowerShell Script As An Administrator: Hi. So I've been searching online on a way to do this yet I cannot find a way to do it. _______________________________________ I need this in specific: I want to double click a PowerShell script file (which will run as an administrator) from Windows Explorer that has...
  7. Removing Office '16 context menu entries?

    in Microsoft Office and 365
    Removing Office '16 context menu entries?: Hello; I've recently installed Office 16 and only just noticed that it's added new context meny entries in my explorer. Upon /r clicking (in the desktop, not on a file), under "new" category, there are now entries for each and every Office 'product': New Word document, New...
  8. delete context menu entry

    in Windows 10 Customization
    delete context menu entry: Hello every one,cannot delete specific entry [img] 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? 13024
  9. Creating a new entry in the context menu

    in Windows 10 Customization
    Creating a new entry in the context menu: 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: [img] Thank you. 39917
  10. Add or Remove Run as administrator Context Menu in Windows 10

    in Windows 10 Tutorials
    Add or Remove Run as administrator Context Menu in Windows 10: How to: Add or Remove Run as administrator Context Menu in Windows 10 How to Add or Remove 'Run as administrator' Context Menu in Windows 10 Some legitimate applications require a full administrator access token (elevated) to perform their functions or tasks. For...

Users found this page by searching for:

  1. ps1 administrator context menu registry key