Is there a way to open command prompt in current folder? - windows

I have a project folder somewhere, and many times I need to open command prompt (on windows 7/8.1/10) and cd to that folder. It would be very handy if there's an option right click > open cmd here.
is there a tool for that?

Just go to your folder location and type "cmd" on the address bar.

Press Shift + Menu, then choose Open Command Window Here. It works.

In win7/8, try right click while holding shift key, should have cmd prompt here

How about to use the PowerShell OpenHere module?
Run PowerShell with elevated permissions and type:
Install-Module OpenHere; Import-Module OpenHere
Set-OpenHereShortcut -ShortcutType:WindowsPowerShell
Disclaimer:
I'm a developer of this module.

use the description in https://stackoverflow.com/a/34534874/1498669 and put "run as administrator" checkbox on
Open 'File Explorer' and enter "shell:sendto" in location bar + hit return to get into this folder
Right mouse click and create a "New"->"Shortcut", put cmd.exe into the path, done
Edit the properties of the shortcut and edit the target to "%windir%\system32\cmd.exe /k pushd"
you can also create a copy of that shortcut, rename it to cmd.exe_admin, select properties, hit button "Advanced" an select the checkbox "run as Administrator"
Now use the "SendTo"-submenu in the explorer right click context menu to send any filepath or folder into the normal or elevated commandbox.
This "shell:sendto"-trick is also very useful for eg. Notepad++ or any program you want to start in "elevated" mode.

Type cmd command in address bar where path or location of the file or folder is shown.

Related

Using cmder . Windows 10

I downloaded Cmder on my PC but I want that the cmd starts on a folder as then I can navigate because if not the cmd starts in the Cmder folder and I can't go anywhere. Can someone help me, please? Wish you understood me!
Very simple and best way to get CMDER wherever you want is adding it to de Windows Context Menu (right click).
Open a terminal as an Administrator
Navigate to the directory you have placed Cmder
Execute .\cmder.exe /REGISTER ALL
If you get a message "Access Denied" ensure you are executing the command in an Administrator prompt.
In a file explorer window right click in or on a directory to see "Cmder Here" in the context menu.
From: https://github.com/cmderdev/cmder#shortcut-to-open-cmder-in-a-chosen-folder
Tip: put the CMDER files in c:\Program Files\CMDER
If I understood you correctly, you want to change the directory you start from each time you open a new terminal.
To do that:
click Win+Alt+t to open the settings
In the settings group 'Startup' choose 'Tasks'
Choose the console you want to modify (e.g. cmd::Cmder, cmd::Cmder as Admin, etc..)
Click the 'Startup dir...' button
Select the directory you want the console to startup in by default
Enjoy!
You dont give us much to go on but you should have a shortcut with which to start cmder perhaps on your desktop something like this.
If not find your installed copy of cmder.exe then Right Click it then select Send To
and then finally select "Desktop (as shortcut)"
Right click the shortcut and select Properties of that shortcut and then add your prefered starting DIRectory after a /start DIRective
If you want to Autorun other start-up commands see
https://stackoverflow.com/a/68185482/10802527

What is the quickest way to get elevated rights in powershell?

It happens again and again that I am in a Powershell session and want to execute a command for which I need admin (elevated) rights.
My current workflow then:
1. pwd (ctrl+c)
2. open a new Powershell (run as administrator)
3. cd ctrl+v
This is very annoying and time-consuming, how can I optimise this?
I guess the standard way of creating a shortcut should do it:
In a command box type where wt.exe to get the file path.
This will most probably return C:\Users\<yourname>\AppData\Local\Microsoft\WindowsApps\wt.exe
Open the path and right-click wt.exe (eventhough in there it shows 0 kb)
Select 'Create Shortcut'
Right-click the new shortcut and in the General tab change the name to Windows Terminal (Admin)
In the Shortcut tab, click the Advanced button and check the box "Run as administrator"
click OK
Drag the shortcut to your desktop
Theo's answer didn't work for me, but this one did. Copied:
Right click -> New -> Shortcut
Type in C:\Windows\System32\cmd.exe /c start /b %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\wt.exe for the location
Give whatever name you want to give, finish.
List item
Right click on the newly created shortcut -> Properties -> Advanced -> Run as administrator

How can I open command prompt in the current directory as a shortcut

I'm just wondering how I can make a shortcut that will open command prompt in the folder it is currently in.
Why I need this.
I save my c program file in the directory Users\PC\Documents\Other\My_Programs\WIP\Project_1\Test\
So I would have to type cd Users\PC\Documents\Other\My_Programs\WIP\Project_1\Test\ every time I want to open the command prompt in that directory.
Is there a shortcut I can make where I can move that shortcut around anywhere (don't need to change the shortcut) and it will open command prompt in the directory it is current in, so I don't need to keep typing cd .....
you can go to the directory and just type start . in the same directory
or you can make a batch file like test.bat and add below line in the same:
cd Users\PC\Documents\Other\My_Programs\WIP\Project_1\Test\
Save it anywhere and whenever you will run that batchfile, it will automatically move PWD to the required directory
Right-click in the open space of your desktop and click New > Shortcut
For the location, type or copy and paste one of the following lines.
%windir%\system32\cmd.exe /k cd Users\PC\Documents\Other\My_Programs\WIP\Project_1\Test\
As commented by aschipfl, you can already do it, (may be OS dependent)!
In Windows Explorer, or I suppose the desktop, just hold down the shift key, right click in a blank area of it and choose Open command window here, (or whatever your locale states).
I think in Windows 10 at least, the option is even available in the Explorer toolbar menu too.

How to open command prompt as administrator from address bar

I use address bar of File explorer to open command prompt in current directory(By typing cmd in address bar). It will open the command prompt as Administrator. I have used Windows 7 OS and I logged in as Domain Administrator.
Now I upgraded the OS to Windows 10. Now I am doing the same, But command prompt is not opened as Administrator.(For local Administrator account it was fine). Is there any way to get command prompt as Administrator(Opening from Address bar) ?
We can add this windows default shortcut for achieving cmd as Administrator in single click
Unfortunately a recent Windows 10 Update has removed the Open command prompt mentioned by #Arvindharaj. However, if you feel comfortable editing the Windows Registry then this site that explains how to activate admin cmd right-click option might be a great option. It was for me.
Here are basic steps after launching regedit.exe:
Go to this address: HKEY_CLASSES_ROOT\Directory\shell
Under this folder create a new key and label it runas.
Double-click the runas folder and check if there’s a “Default” key. Right-click it and choose “Modify.”
Once you click “Modify,” the “Edit String” box shows up. Type Open Administrator Command Prompt Here in the Value data box.
Next, in the same folder, create a new string value (right-click the runas folder and choose New and select String Value). Label it as NoWorkingDirectory.
Under the HKEY_CLASSES_ROOT\Directory\shell\runas path, create another key and label it as command.
Double click the folder and you’ll see the Default string value. Right click and choose “Modify.” Under the Value data, enter cmd.exe /k cd %1 and click OK.
FYI - I think this last step is wrong btw. The cmd prompt will launch as admin but in its default folder. So instead enter "cmd.exe /s /k pushd %V" and this should launch the admin prompt in the folder you right-clicked on.
I've tried #Alex's solution, but it still didn't work, CMD still evaluated without Administrator privileges.
I only have it working after running the following command in command prompt:
> REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
/v EnableLUA /t REG_DWORD /d 0 /f
And restart the Computer after this.
Can't say that this only helps, but maybe this in addition to #Alex's did the job.
Adding up to response from Aravindharaj G :
1> In File Explorer go to the window where you want to open PowerShell / Command Prompt
Use HotKey ( ALT (Hold) + F > S > A ) will open PS in that location.
2> Using Top Menu File > Open Command Prompt ( or Open Window PowerShell ) > Open Command Prompt as Administrator > now SELECT
"Add to Quick Access Toolbar"
This will add a Tiny icon in all File Explorer Windows for all.

How can I open a cmd window in a specific location?

How can I open a cmd window in a specific location without having to navigate all the way to the directory I want?
This might be what you want:
cmd /K "cd C:\Windows\"
Note that in order to change drive letters, you need to use cd /d. For example:
C:\Windows\System32\cmd.exe /K "cd /d H:\Python\"
(documentation)
Assuming that in File Explorer you have opened the target directory/folder, do this:
Click on address bar, alternatively press Alt+D
Now when address bar is highlighted, type cmd in the bar.
Press Enter key
You will notice that command prompt from that folder
If you have Windows Vista or later, right-click on the folder icon in Explorer while holding the Shift key, and then click on the "Open command window here" or "Open PowerShell window here" context menu option.
If you're already in the folder you want, you can do one of the following:
[only Win8+] Click the Explorer Ribbon's File button, then click on "Open command window here" or "Open PowerShell window here".
Shift-right-click on the background of the Explorer window, then click on "Open command window here" or "Open PowerShell window here". (recommended by Kate in the comments)
[only Vista or Win7] Hold down Shift when opening the Explorer File menu, then click on "Open command window here". If you can't see the menu bar, open the File menu by pressing Alt-Shift-F - Alt-F to open the File menu, plus Shift.
For Windows XP, use the PowerToy mentioned by dF to get the same function.
From Windows 7 up to some versions of Windows 10, it is very simple to open a command prompt anywhere you wish, without navigation using command "cd".
Try the following one.
Click the mouse's right button by holding Shift key .
It will produce an option like this. Then simply select the "Open command window here " option.
The latest versions of Windows 10 have replaced this feature with "Open Powershell here".
Try out this "PowerToy" from Microsoft:
Open Command Window Here
This PowerToy adds an "Open Command
Window Here" context menu option on
file system folders, giving you a
quick way to open a command window
(cmd.exe) pointing at the selected
folder.
EDIT : This software will not work on any version of Windows apart from Windows XP.
On Windows Vista, Windows 7 and Windows 10 simply hold down the Shift key and right-click on a folder.
The context menu will contain an entry titled: "Open command window here"
Update: Type "cmd" in the address bar of Explorer and press enter
Update 2: In windows 10, go to file menu and select "Open Windows PowerShell". There is an option for running as administrator.
Update 3: You can also add a quick access shortcut by going to file menu, right click on "Open windows Powershel" and select "Add to Quick Access Toolbar" and after that with one single click you can access the powershell immediately
Use the /K switch. For example
cmd /K "cd /d c:\WINDOWS\"
Will create a cmd window at the C:\Windows directory
Just write cmd in the address bar, it will open in the current folder.
In windows go to folder location in file explorer remove path and type cmd and press enter. and path will open in cmd.
Also, here is a shortcut to open a console in any windows folder:
Open any folder on windows explorer.
Press Alt + D to focus the adress bar
type cmd and press enter
Very practical shortcut.
pushd command sets the current folder. so:
cmd /k "pushd D:\Music"
In Windows 8, you can click the address bar and type "cmd" (without quotes) and hit enter. This will open the cmd window in the current path.
Easiest way is to goto the address bar of the Windows Explorer and type cmd there. It will automatically open the command prompt window for you.
If you are starting cmd from taskbar, this is what you need to do:
right click --> rightclick on Command Prompt --> Properties
Then in the properties window change the value of Start in:
This solution doesn't work for opening command prompt as administrator
Create a shortcut and edit the "Start In" property of the shortcut to the directory you want the cmd.exe to start in.
I just saw this question and cannot help to post my AutoHotkey script for cmd on Windows XP. You can spot the hot keys in the script. The nice thing is when your current windows is Explorer, the cmd will open in the path showing in the address bar.
I keep this script in a folder where I store all green tools (including AutoHotkey). For a new machine, I just copy the folder, double click the script to associate .ahk with AutoHotkey and create a shortcut in my startup folder. It is faster than installing PowerToys.
; Get working folder
GetWorkingFolder() {
if WinActive("ahk_class ExploreWClass") or WinActive("ahk_class CabinetWClass") {
ControlGetText, path, Edit1
return %path%
} else if WinActive("FreeCommander") {
Send, {CTRLDOWN}{ALTDOWN}{INS}{ALTUP}{CTRLUP}
Sleep, 100
return clipboard
} else {
return "C:\"
}
}
#IfWinActive,
#c::
path := GetWorkingFolder()
Run, %ComSpec%, %path%
return
; PowerShell
#+C::
path := GetWorkingFolder()
Run, %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe, %path%
return
#^c::
Run, %ComSpec%, %temp%
return
#!c::
path := GetWorkingFolder()
Run, %comspec% /k "%VS90COMNTOOLS%vsvars32.bat", %path%
return
; irb
#!b::
path := GetWorkingFolder()
Run, c:\cygwin\bin\ruby /usr/bin/irb, %path%
return
; Bash
#b::
path := GetWorkingFolder()
Run, bash --login, %path%
return
; Paste in console
+INS::
if WinActive("ahk_class ConsoleWindowClass") {
WinGetPos, x, y, w, h, A
MouseGetPos, mx, my
;MsgBox x=%x% y=%y% w=%w% h=%h% mx=%mx% my=%my%
if (mx < 10)
mx = 10
else if (mx > w - 30)
mx := w - 30
if (my < 40)
my = 40
else if (my > h)
my := h - 10
MouseClick, right, mx, my
}
return
For anyone who is interested, you can find this script at rwin on github
This will add entries to the context-menu to launch a command window that is automatically navigated to the directory you clicked.
Usage:
Right-click a folder icon (or the empty background area inside an already open folder)
and click either "Open in Terminal" or "Open in Terminal (Admin)".
You can also right click files to execute them with a command window.
When the file is done running you are left with a command window that is navigated to the files directory.
Open_in_Terminal.reg
Windows Registry Editor Version 5.00
; Admin versions.
; Right click on a folder in a directory.
[HKEY_CLASSES_ROOT\Directory\shell\OpenCommandWindowHereAsAdministrator]
#="Open in Terminal (Admin)"
"Icon"="cmd.exe"
"HasLUAShield"=""
"Position"="middle"
[HKEY_CLASSES_ROOT\Directory\shell\OpenCommandWindowHereAsAdministrator\command]
#="cmd.exe /c powershell.exe -Command \"Start-Process cmd -Verb runas -ArgumentList '/k pushd \"%1\"'\""
; Right click on nothing in a directory, i.e. the "background" of the directory.
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCommandWindowHereAsAdministrator]
#="Open in Terminal (Admin)"
"Icon"="cmd.exe"
"HasLUAShield"=""
"Position"="middle"
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCommandWindowHereAsAdministrator\command]
#="cmd.exe /c powershell.exe -Command \"Start-Process cmd -Verb runas -ArgumentList '/k pushd \"%V\"'\""
; Right click on nothing in a library directory, i.e. the "background" of the library directory.
[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\OpenCommandWindowHereAsAdministrator]
#="Open in Terminal (Admin)"
"Icon"="cmd.exe"
"HasLUAShield"=""
"Position"="middle"
[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\OpenCommandWindowHereAsAdministrator\command]
#="cmd.exe /c powershell.exe -Command \"Start-Process cmd -Verb runas -ArgumentList '/k pushd \"%V\"'\""
; Right click on a file in a directory.
[HKEY_CLASSES_ROOT\*\shell\OpenWithCommandWindowAsAdministrator]
#="Open in Terminal (Admin)"
"Icon"="cmd.exe"
"HasLUAShield"=""
"Position"="middle"
[HKEY_CLASSES_ROOT\*\shell\OpenWithCommandWindowAsAdministrator\command]
#="cmd.exe /c powershell.exe -Command \"Start-Process cmd -Verb runas -ArgumentList '/k pushd \\\"%W \\\" && \\\"%1\\\"'\""
; Non-Admin versions.
; Right click on a folder in a directory.
[HKEY_CLASSES_ROOT\Directory\shell\OpenCommandWindowHere]
#="Open in Terminal"
"Icon"="cmd.exe"
"Position"="middle"
[HKEY_CLASSES_ROOT\Directory\shell\OpenCommandWindowHere\command]
#="cmd.exe /k pushd \"%1\""
; Right click on nothing in a directory, i.e. the "background" of the directory.
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCommandWindowHere]
#="Open in Terminal"
"Icon"="cmd.exe"
"Position"="middle"
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCommandWindowHere\command]
#="cmd.exe /k pushd \"%V\""
; Right click on nothing in a library directory, i.e. the "background" of the library directory.
[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\OpenCommandWindowHere]
#="Open in Terminal"
"Icon"="cmd.exe"
"Position"="middle"
[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\OpenCommandWindowHere\command]
#="cmd.exe /k pushd \"%V\""
; Right click on a file in a directory.
[HKEY_CLASSES_ROOT\*\shell\OpenWithCommandWindow]
#="Open in Terminal"
"Icon"="cmd.exe"
"Position"="middle"
[HKEY_CLASSES_ROOT\*\shell\OpenWithCommandWindow\command]
#="cmd.exe /k pushd \"%W\" && \"%1\""
This took a lot of effort to make so if you're feeling generous then feel free to send a paypal donation to help me overcome the PTSD of debugging and testing it :)
An uninstaller if you need one:
Open_in_Terminal_Remover.reg
Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\Directory\shell\OpenCommandWindowHereAsAdministrator]
[-HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCommandWindowHereAsAdministrator]
[-HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\OpenCommandWindowHereAsAdministrator]
[-HKEY_CLASSES_ROOT\*\shell\OpenWithCommandWindowAsAdministrator]
[-HKEY_CLASSES_ROOT\Directory\shell\OpenCommandWindowHere]
[-HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCommandWindowHere]
[-HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\OpenCommandWindowHere]
[-HKEY_CLASSES_ROOT\*\shell\OpenWithCommandWindow]
Update: This is built into Windows now. See this answer.
The XP powertoy is a good option, but I thought I'd post another, in case you'd like to "roll your own". Create a text file, name it anything.reg, paste in the code below, save it, then double-click on it to add it to the registry (or just add the info to the registry manually if you understand what's going on in this .reg file).
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell\Command_Prompt_Here...]
#="Command Prompt Here..."
[HKEY_CLASSES_ROOT\Folder\shell\Command_Prompt_Here...\command]
#="cmd.exe \"%1\""
Update: After an Windows-update, Win10 removed the cmd-here feature. To reactivate it you've to use:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\cmd]
#="#shell32.dll,-8506"
"Extended"=""
"NoWorkingDirectory"=""
"ShowBasedOnVelocityId"=dword:00639bc8
[HKEY_CLASSES_ROOT\Directory\shell\cmd\command]
#="cmd.exe /s /k pushd \"%V\""
The entry ShowBasedOnVelocityId is mandatory
This answer is for windows 10.
Create a command prompt shortcut in the folder wherever you want, then right click on that shortcut
and
For windows 7 or later, inside the target folder address bar just type cmd. That is it. It will open up command prompt with path set to your present directory.
In File Explorer, press and hold the Shift key, then right click or press and hold on a folder or drive that you want to open the command prompt at that location for, and click/tap on Open Command Prompt Here option.
I see that there are multiple answers, some are quite complex :) , strange to see them. You just have to open any windows folder window, navigate to your desired folder and focus on address bar and enter "cmd" and press enter, you would be presented with new command prompt window directly with the folder path or location that we already navigated in windows folder window.
In case you want to see these steps with clear images you can check out
how to open command prompt in a specific folder directly
Make the shortcut to cmd.exe with params /S /K pushd "C:\YOUR FOLDER\"
For windows :
Select the folder which you want to open in command prompt - After selection,
Keeping the 'Shift key' pressed. Right click there and choose option
"open command window here"
In Windows go to the specific folder, then click on the file explorer path and remove it then type cmd and click enter.. and in cmd your specific folder with its path will open..
In Windows Explorer - shift + right mouse click above folder "Open command window here" option show up in the menu. Or in language of your Windows version.
<===||==========> On Windows 10 <==========||===>
Assuming that in File Explorer you have opened the target directory/folder, do this :
Click on address bar, alternatively press Alt + A
Now when address bar is highlighted, type cmd in the bar.
Press Enter key
For a powershell window :
Just press Alt + f + s + a
There is a simplier way I know. Find cmd.exe in start menu and send it to Desktop as shortcut. Then right-click it and choose properties. You will see "Start in" box under the "Target". Change that directory as whatever you'd like to set. Click OK and start cmd.exe which is in your Desktop. In my opinion, it's a very easy and certain solution :)
This program always opens cmd.exe in the current path of your Explorer:
https://github.com/jhasse/smart_cmd
You can also pin it to your taskbar and then use WindowsKey+[1-0] as a keyboard shortcut.
If you use Total Commander there is a field in the bottom for this. It shows the active directory you are currently in and will run the entered command in that directory.

Resources