Jump to content

cmd window in the current folder from context menu


Recommended Posts

hi people :hello:

as you know we can open a new command window in a folder from context menu. what i want is a little different from this. i wanna open a cmd window in the current directory i am in. and i prepared a reg file for this. but it works when you right click on a folder in in the current directory. (heres my question) i want it to be placed at context menu without right clicking another folder in current directory.

can show me a way to do this or correct my reg file pls ?

thanks in advance :)

================curdir.reg====================

Windows Registry Editor Version 5.00

;----- Get a new Right-click menu option (command box)

;-----

[HKEY_CLASSES_ROOT\Directory\shell\Command Prompt CurDir]

@="Command P&rompt CurDir"

[HKEY_CLASSES_ROOT\Directory\shell\Command Prompt CurDir\command]

@="cmd.exe cd %~p0"

========================================

Link to comment
Share on other sites


You should try this:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Drive\Shell\DosHere]
@="Command P&rompt"
[HKEY_CLASSES_ROOT\Drive\Shell\DosHere\Command]
@="cmd.exe /k pushd \"%1\""
[HKEY_CLASSES_ROOT\Directory\Shell\DosHere]
@="Command P&rompt"
[HKEY_CLASSES_ROOT\Directory\Shell\DosHere\Command]
@="cmd.exe /k pushd \"%1\""
[HKEY_CLASSES_ROOT\Folder\Shell\DosHere]
@="Command P&rompt"
[HKEY_CLASSES_ROOT\Folder\Shell\DosHere\Command]
@="cmd.exe /k pushd \"%1\""

Link to comment
Share on other sites

@DL.

hey friend i tried your solution but works when you right click on a folder and for that folder. its not what i mean. i wanna open cmd window without right clicking on a folder. thanks anyway :)

@benners

hi benners i tried your software but it doesnt work for desktop. i am pressing ctrl+m to activite it but it didnt work out but inside a folder. thanks anyway :)

Link to comment
Share on other sites

Do you mean that you want to have "Open CMD-window" in the right-click wherever you right-click (like right-clicking on an empty space in explorer or the desktop)?

If so, it can be done but it requires some work and extensive knowledge of some specific parts of the registry. If I had the time and really wanted to do it I could probably learn how to write something like that, but there are others (maybe even on this forum?) who have already done that.

Search for a shell extension that does what you want and post the link here if you find one.

Link to comment
Share on other sites

This add to the right click a template for a cmd this is like adding a new text file from the right click.

Dim Act,All_UP_T, Fso, Sd, Template, User_T

Set Act = CreateObject("Wscript.shell") : Set Fso = CreateObject("Scripting.FileSystemObject")

Template = (SD & "\Windows\System32\ShellExt") : User_T = Act.SpecialFolders("Templates")

All_UP_T = Act.ExpandEnvironmentStrings("%AllUsersProfile%\Templates")

Set Ts = Fso.CreateTextFile(SD & "\Windows\System32\ShellExt\Template.cmd")

Ts.WriteBlankLines 1

ts.Close

Act.RegWrite "HKCR\.cmd\ShellNew\FileName", "template.cmd"

Link to comment
Share on other sites

I know its irrelevant to the original question, sorry, but here is a cmd solution to GSMs vbscript.

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SET LOCN=%SystemRoot%\ShellNew
SET FNAME=MT.cmd
SET ISIT=
IF EXIST "%LOCN%" (
SET ISIT=Y
IF EXIST "%LOCN%\%FNAME%" DEL /Q/F "%LOCN%\%FNAME%"
) ELSE (
MD "%LOCN%"
)
COPY NUL "%LOCN%\%FNAME%">NUL
REG ADD HKCU\Software\Classes\.cmd\ShellNew /v FileName /d "%FNAME%" /f>NUL
REG ADD HKCU\Software\Classes\cmdfile\ShellNew /v FileName /d "%FNAME%" /f>NUL
PING -N 4 127.0.0.1>NUL
IF "%ISIT%"=="Y" (
DEL /Q "%LOCN%\%FNAME%"
) ELSE (
RD /S/Q "%LOCN%"
)
ENDLOCAL
GOTO :EOF

Its a little longer than necessary due to setting variables, error trapping and putting everything in a nice easy to follow line by line structure.

Link to comment
Share on other sites

@gunsmokingman

hello gunsmokingman :hello:

thanks for your suggestion but its not what i need and i prefer reg or cmd entries rather than vbs.

@Yzöwl

hello friend as you said its irrelevant about my question. however i will keep it. maybe i might need such a thing.

and i insist on my question. because its very handy for my computing skills.

thanks anyway :)

Link to comment
Share on other sites

This is the best "nearly what you need" I know of:

http://gabrieleponti.com/software/

Send To Toys 2.3

- Send To "Command Prompt" opens a DOS console window, setting the current directory to the selected folder. If the selection was a file, the folder containing the file will be the active directory and the name of the file will be typed for you at the prompt. Hold down the CTRL key to change the active directory to a different folder.

Of course to send a "open dos prompt" command you need an argument, if you select a directory, this add-on works like the Registry Tweak posted early, if you select a file, it opens to the directory where the file is and types the name of the file on the command line.This is of course VERY useful if the file is a .exe, .bat or .cmd, as you just add the (optional) parameters and hit enter.If the file is not an executable, you will need to use a bit of backspace.

jaclaz

Link to comment
Share on other sites

  • 2 weeks later...

Merhaba,

Read Extension 2 - Handling a right-click in a directory window on page

http://codeproject.com/shell/ShellExtGuide7.asp . You can modify the code by this purpose.

Only change the messagebox code to a sitable one as follows

STDMETHODIMP CBkgndCtxMenuExt::InvokeCommand ( LPCMINVOKECOMMANDINFO pInfo )

{

WORD wCmd = LOWORD( pInfo->lpVerb );

// If lpVerb really points to a string, ignore this function call and bail out.

if ( 0 != HIWORD( pInfo->lpVerb ))

return E_INVALIDARG;

// The command ID must be 0 or 1 since we have two menu items.

if ( wCmd > 1 )

return E_INVALIDARG;

TCHAR szMessage [MAX_PATH + 300];

if ( 0 == wCmd )

{

wsprintf ( szMessage, _T("cd /d %s"), m_szDirClickedIn );

}

else

{

return E_INVALIDARG;

}

_spawnl(_P_NOWAIT,"C:\\windows\\system32\\cmd.exe","/K",szMessage,NULL);

return S_OK;

}

I tried it and it was working, read the question parts from lesson 2 to overcome the compile errors if you use .NET.

Link to comment
Share on other sites

@morftp

hi that is merhaba :)

pls let me ask you a private question before i thank for your help :)

are you a turkishman who lives in USA or are you an amerikan who knows turkish ? :)

in both cases i'm glad to meet you... and if you find it suitable we can write each other. i want to improve my english and get a considerable toefl score.

anyway as soon as i get a proper time to try, i will try and give a feedback

thank you very much friend

Link to comment
Share on other sites

  • 4 weeks later...

hi friends

after a long time i am here again. :) i am beaten about this tweak. because it seems more copmlicated than i expect. if you give me an instant solution i will be so glad. if not, there's nothing to do more for this. :(

thanks anyway....

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...