Command Prompt/Powershell Start with certain conditions

Share your favorite FastKeys commands
Post Reply
User avatar
travibe
Posts: 20
Joined: Nov 2nd, ’20, 23:29

Post by travibe » Jul 19th, ’25, 01:47

Hey Tom or anyone else around these parts that are long time members,

Have a bit of conditional code I'd appreciate help creating. I'm still using the code you, Tom, helped me with a while back where a window appears after a shortcut where I can choose Cmd Prompt or Powershell

Command Prompt:: C:\Windows\System32\cmd.exe
/Powershell:: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

If I can make two changes:
1) Can both Cmd Prompt and Powershell be changed to open at the C:\ directory? Currently opening at the location my portable Fastkeys is located.
2) Can there be a seperate option for both to open and automatically have highlighted text entered into the window? I.e. If i have "johnny" highlighted in a window somewhere, I press the shortcut and it opens the Cmd Prompt or Powershell at C:\johnny?


Thank you much!
User avatar
Tom
Posts: 915
Joined: Nov 24th, ’15, 23:39

Post by Tom » Jul 22nd, ’25, 18:14

Try using the following paths:

C:\Windows\System32\cmd.exe /K "cd /d C:"
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command "Set-Location c:"

CMD Documentation:
https://ss64.com/nt/cd.html
Post Reply