Open VBS file with admin command prompt context menu


  1. Posts : 519
    Win7 Pro X64, Win10 Pro x640
       #1

    Open VBS file with admin command prompt context menu


    @Brink

    VBS files have, by default, a context menu to Open with command prompt. I would like to add an additional option to Open with command prompt as admin. The command to open VBS files, standard privileges, is something like

    Code:
    cmd.exe "%SystemRoot%\System32\CScript.exe" "%1" %""
    I believe that I need a powershell command/script to elevate. I cannot use the runas key to open with command prompt since it is already used to run VB files with script.exe as admin.

    Add Run as administrator to Context Menu of VBS Files in Windows 10


    So how do I modify the command
    Code:
    cmd.exe "%SystemRoot%\System32\CScript.exe" "%1" %""
    to run elevated, probably with powershell?

    Thanks!
      My Computer


  2. Posts : 68,668
    64-bit Windows 11 Pro for Workstations
       #2

    You would use this in the command key.

    @="PowerShell -windowstyle hidden -Command \"Start-Process cmd -ArgumentList '/s,/c,start CScript.exe \"\"%1\"\" %*' -Verb RunAs\""
      My Computers


  3. Posts : 519
    Win7 Pro X64, Win10 Pro x640
    Thread Starter
       #3

    Great. I will try out this evening.

    Thanks!
      My Computer


  4. Posts : 68,668
    64-bit Windows 11 Pro for Workstations
       #4

      My Computers


  5. Posts : 519
    Win7 Pro X64, Win10 Pro x640
    Thread Starter
       #5

    The command works. VBS files open with admin command prompt. Are there any other script file extension types like VBS I can create similar context menu entries to open in wscript, runas wscript (elevated), open in command prompt and open in admin prompt? The only other files I can think of are javascript files. The correct registry entry to modify would be jsfile, right?
    Thanks!
      My Computer


  6. Posts : 117
    Windows
       #6

    bamajon1974 said:
    The command works. VBS files open with admin command prompt. Are there any other script file extension types like VBS I can create similar context menu entries to open in wscript, runas wscript (elevated), open in command prompt and open in admin prompt? The only other files I can think of are javascript files. The correct registry entry to modify would be jsfile, right?
    Thanks!
    You can create any script you want, use WinaeroTweaker to create an elevated shortcut for it and then use EcMenu to add said elevated shortcut to your context menu... just for simplicity and quickness...
      My Computer


  7. Posts : 7,606
    Windows 10 Home 20H2
       #7

    Winaero Tweaker is not needed. TenForums already has the following:

    How to Add Create Elevated Shortcut to New Context Menu in Windows 10
      My Computer


  8. Posts : 519
    Win7 Pro X64, Win10 Pro x640
    Thread Starter
       #8

    Did some reading and it seems that VBS, VBE, WSF, WSH, JS and JSE would be the executable script files that might benefit from the additional commands. Any comments from the experienced coders?
      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 21:06.
Find Us




Windows 10 Forums