Open a PowerShell console and manually run the script from the command line. We have 3 solutions to fix this so that the PowerShell console stays open after the script has finished running: 1. If the script gives output that the user wants to see, or if it throws an error, the user won’t have time to read the text. When running a script by double-clicking it, or by right-clicking it and choosing Run With PowerShell or Open With Windows PowerShell, if the script completes very quickly the user will see the PowerShell console appear very briefly and then disappear. I originally included this as a small bonus section at the end of my other post about fixing the issue of not being able to run a PowerShell script whose path contains a space, but thought this deserved its own dedicated post. Windows Registry Editor Version 5.Keep PowerShell Console Window Open After Script Finishes Running Some of these other answers say to add the key into HKCR\Directory\shell but I found that for me it only worked with the keys going into HKLM\SOFTWARE\Classes\Directory\shell Windows Registry Editor Version PowerShell -NoExit -Command Set-Location -LiteralPath PowerShell -NoExit -Command Set-Location -LiteralPath '%V'"Ĭreate a file named PowershellHereContextMenu.reg with the contents below, right click on it and "Merge". reg file and run the file to add the key and it should work from there. Just copy these into a blank notepad file then save as a. You must navigate using Computer -> C: -> to -> Some -> Target -> Directoryīy adding the registry keys below, in Windows 10, I managed to get the Open PowerShell Here option in my SHIFT + RClick context menus. Clicking Documents under the Libraries header) Note: In Windows 7, the HKCR\Directory\Shell does not work if you use the toolkit on the side of the explorer Note: If you have an explorer window open, you may need to close it and reopen it to get the changed to take effect. The key name for the elevated command shell is " runas", which is why it comes after the PowerShell entry. Note: Context menu entries are displayed alphabetically, based on their Registry keys. As you can see, you can also add a context menu entry to run an elevated command window, i.e., Run as Administrator. I've highlighted the console and PowerShell commands. As soon as you run it, the context menu entries will show up! My comments show you each section.Īfter you save the file, run it by double-clicking on it. (I would have included a copy of the file, but I couldn't figure out if attachments were possible.) If you want to exclude the command from one of the entry, just comment out the appropriate section with semicolons. Copy the exact text of the code above, paste it into the new file, and save it. So, with your favorite text editor, open a new file named OpenPowerShellHere.reg. Add context menu entry to Windows Explorer drive PowerShell window -NoExit -Command Set-Location -LiteralPath '%V'" Add context menu entry to Windows Explorer PowerShell window -NoExit -Command Set-Location -LiteralPath '%V'" Here is a copy of my OpenPowerShellHere.reg file, which puts the command in the context menu of each of the Explorer objects, the window background, the folder, and the drive icon: Windows Registry Editor Version 5.00
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |