0

I want to run PowerShell from the context menu of folders, disks, files, background catalogs

I tried different options from such questions on this forum, but none works.

Now I have like this enter image description here

with such a command

"D:\PATH\ConEmu64.exe" -inside -config "shell" /REUSE  -dir "%1" -run {powershell} -cur_console:n

For example, with such

@="C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -windowstyle hidden -Command \"Start-Process powershell  -ArgumentList '-NoExit', '-Command cd %V' -Verb runAs\""

Reports that there is no access

1 Answer 1

2

This code will set up a Run with PS item in the SendTo menu:

Clear-Host

   #Create SendTo Shortcut
 
   $PgmBase = "Run with PS"

   $SendToPath = "C:\Users\$env:USERNAME\AppData\Roaming\" +
                 "Microsoft\Windows\SendTo\"
                 
   If (!(Test-path -Path "$SendToPath$PgmBase.lnk")) {
     
     $WshShell = New-Object -comObject WScript.Shell
     $Shortcut = $WshShell.CreateShortcut(
                 "$SendToPath\$PgmBase.lnk")
     $Shortcut.TargetPath   = 
      "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"   
     $Shortcut.Arguments    = "-File $Args"
     $Shortcut.WindowStyle  = 7
     $Shortcut.IconLocation = 
      "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
     $Shortcut.Save()
   
     "The $PgmBase option has been added to" +
                "File Explorer SendTo menu."
              
   } #End If (!(Test-Path...

   Else { "Run with PS SendTo shortcut already exists!" }

HTH

Sign up to request clarification or add additional context in comments.

2 Comments

Well, I can run not from "Send to"?
Why can't you use SendTo? It's a standard part of the context menu.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.