Click here to Skip to main content
Licence 
First Posted 16 Nov 2000
Views 177,075
Bookmarked 33 times

Starting a DOS prompt from Windows Explorer

By | 16 Nov 2000 | Article
How to start a dos prompt by right-clicking on a folder in Windows Explorer

Introduction

Even if a lot of operations can be done directly from the Windows Explorer, it is still necessary, sometimes, to open a DOS prompt to perform a particular task. Typing the full path of a directory can be really annoying. Recently, I've learned a way of starting a DOS prompt with its current directory set to a particular folder The following steps will show you how to add an entry in the pop-up menu that appears when you right-click on a folder from the Windows Explorer. Selecting this entry will open a DOS prompt with its current directory set to the folder you just right-clicked.
  1. Open your registry (regedit)

  2. Go to the following key: HKEY_CLASSES_ROOT\Folder\shell
  3. Add this key: CmdPrompt and set its default value to: "Command Prompt"
  4. Under this new key, add the following key: Command and set its default value to: "c:\winnt\system32\cmd.exe"

You should now have this tree in your registry:

That's it. Now, whenever you will right-click on a folder, the pop-up menu will contain an entry called "Command Prompt".

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Daniel Larocque

Web Developer

Canada Canada

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralOr paste cmd.bat into the directory... Pinmembercraig4wd22:05 27 Aug '08  
GeneralRe: Or paste cmd.bat into the directory... Pinmemberaprilkacau10:31 10 Oct '10  
GeneralNOTE: change Path on XP to WINDOWS for command key Pinmembertedzzz6:19 14 Sep '06  
GeneralAllow UNC paths PinmemberJose Xavier6:04 4 Nov '04  
QuestionDOS or not? Pinmemberajvn723:41 24 Sep '04  
GeneralAn even easier way for XP Pinmembercoderitr3:28 22 Jun '03  
GeneralRe: An even easier way for XP Pinmembersaltynuts200220:03 9 Sep '03  
GeneralRe: An even easier way for XP PinsussAnonymous4:08 17 Dec '03  
GeneralRe: An even easier way for XP PinsussAnonymous9:38 22 Jun '04  
GeneralHow to delete/edit erroneous file folder type associations Pinmemberkpatel10815:11 29 Oct '04  
GeneralRe: An even easier way for XP Pinmembergabmurillo5:24 20 Jul '04  
GeneralRe: An even easier way for XP Pinmemberkpatel10818:23 20 Dec '04  
GeneralRe: An even easier way for XP Pinmemberlars@phobe.com21:49 17 Apr '05  
GeneralTry this Pinmembermgomez2:34 15 Jan '03  
GeneralWin XP problem PinmemberGerard Nicol15:01 22 May '02  
GeneralKeeping it simple is great, but taking it a bit further... PinmemberDaniel Madden20:55 28 Apr '02  
Hi Daniel,
 
First off let me say GREAT name!!
 
I wish I would have seen this before I made a program that did this using COM (which can be used to go a bit further than your implementation). What I did is create a console program called "CmdExec", then went to "OLE View" and copied the interface of "ShellUtils" to a text file called "ShelUtil.idl". I then ran "C:\> MIDL ShelUtil.idl /h ShelUtil.h" which created the .h and .c files (which I added to my project). Then I did exactly what you said in the registry, but I put the path to the "CmdExec.exe". I then wrote a quick main() (shown below).
 
Cool | :cool: I can send you the project if you like.. Cool | :cool:
 
It works the same as yours does Smile | :) , but I think this way let's you take it a bit further if you want (using COM).
 
There are other commands for the IExec interface you can also use (not to mention another interface).
 
Run(BSTR bstrFile,BSTR bstrVerb);
NewFolderHere(BSTR curFolderName,BSTR newFolderName);
ExecCommand(BSTR curFolderName,BSTR bstrCmd);
 
Here is the main() function...
 
int main()
{
//
// Intilize COM
HRESULT hr = CoInitialize(0);
//
// Use the SUCCEEDED macro and see if we can get a pointer
// to the interface
if(SUCCEEDED(hr))
{
//
// A pointer to the IExec interface
IExec *pIExec;
//
// Create the Instance.
hr = CoCreateInstance(CLSID_Exec,NULL,CLSCTX_INPROC_SERVER,IID_IExec,(void**) &pIExec);
if(SUCCEEDED(hr))
{
char szBuf[256];
//
// Get the curent directory...if it fails, put "C:\" in it.
if (GetCurrentDirectory(256, szBuf) == 0)
sprintf(szBuf,"C:\\");
//
// Put it into a BSTR
BSTR bstrDir = _bstr_t(szBuf);
//
// Now create the DOS window with the current directory
pIExec->DosFromHere(bstrDir);
//
// Release the poiter to the interface
pIExec->Release();
}
}
//
// Uninitialize COM
CoUninitialize();
//
// bye...
return 0;
}
 
Regards,
 
Dan
GeneralVery good! Man PinmemberAnonymous12:58 10 Apr '02  
QuestionHow to do this to a file? PinmemberNiklas7920:34 18 Feb '02  
AnswerRe: How to do this to a file? PinmemberAnonymous9:16 18 Apr '02  
GeneralSafest yet Easiest way Pinmembermakemani12:31 29 Jan '02  
GeneralRe: Safest yet Easiest way PinmemberAnonymous3:07 27 Mar '02  
GeneralRe: Safest yet Easiest way PinmemberAnonymous13:11 10 Apr '02  
GeneralRe: Safest yet Easiest way Pinmemberimuav14:24 3 May '07  
GeneralRe: Safest yet Easiest way PinmemberHogfather5:13 13 May '08  
GeneralThat's always been good.... Pinmembercero9:46 20 Dec '01  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120529.1 | Last Updated 17 Nov 2000
Article Copyright 2000 by Daniel Larocque
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid