Hi,
I'd like to be able to write a batch file and run a command through cmder. I've got this so far
START c:\tools\cmder\cmder.exe /START my-command
However this doesn't seem to run the command. I've been searching around to try and figure out how to do this but I can't find anything. Is it possible? If so I'll submit a pull request and add it to the documentation.
Hi,
For start cmder with specified command on windows, create one file .bat with the following content:
@echo off
set CMDER_ROOT=%~dp0
start %CMDER_ROOT%\vendor\conemu-maximus5\ConEmu.exe /icon "%CMDER_ROOT%\cmder.exe" /title Cmder /loadcfgfile "%CMDER_ROOT%\config\ConEmu.xml" /cmd cmd /k "%CMDER_ROOT%\vendor\init.bat cd %CD% && %~1"
then call this .bat with your command:
"path/to/my/file.bat" "<yourcommand>"
I hope this helps you :)
Thanks a million, I'll test this out over the next week!
Hi, sorry for taking so long to reply - this worked fine. Thanks!
I'm trying to do the same, I have a file called cmder.bat with the following contents:
@echo off
set CMDER_ROOT=C:\Cmder
start %CMDER_ROOT%\vendor\conemu-maximus5\ConEmu.exe /icon "%CMDER_ROOT%\cmder.exe" /title "Homestead VM" /loadcfgfile "%CMDER_ROOT%\config\ConEmu.xml" /cmd cmd /k "%CMDER_ROOT%\vendor\init.bat cd %CD% && %~1"
And am running test.bat (in the same directory):
"cmder.bat" "w: && cd \tools\homestead"
This causes both a ConEmu prompt and a Cmder prompt to pop up. The commands get executed in the Cmder window but the ConEmu windows stays open with the Press Enter or Esc to close the console... message.
Is there any way to close the ConEmu window?
And another thing I noticed: when creating a new console (via de title bar of the Cmder prompt > New Console...) it starts the same .bat file. Would there be any way to 'reset' this to the defaults?
I like to make an alias to 'cd' into a deep directory, I created the alias on .minttyrc on my home folder.. but the problem is cmder is not loading that .minttyrc file when startup. How can I make cmder to load that file on (cmder)startup ?
I still get this weird second ConEmu window...
any update on this after 2 years?
I think if you're doing this from within cmder you can use something like this:
cmd /k "%CMDER_ROOT%\vendor\init.bat cd %CD% && %~1"
Whereas if you need the command to run from outside of cmder, you can then do something like:
set CMDER_ROOT= <PATH_TO_CMDER>
start %CMDER_ROOT%..\Cmder.exe /START "cmd /k "%CMDER_ROOT%\vendor\init.bat cd %CD% && %~1""
Also this can be done if you want to launch Powershell and not cmd (from within cmder):
start PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command "Invoke-Expression '. ''%ConEmuDir%\..\profile.ps1'''; Invoke-Expression %~1"
And for Powershell external from cmder:
set CMDER_ROOT= <PATH_TO_CMDER>
start %CMDER_ROOT%..\Cmder.exe /START "cmd /k "%CMDER_ROOT%\vendor\init.bat && PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command Invoke-Expression '. ''%CMDER_ROOT%\vendor\profile.ps1'''; Invoke-Expression %~1""
This worked for me:
`@echo off
set CMDER_ROOT=**insert_path_to_cmder_folder**
start %CMDER_ROOT%\vendor\conemu-maximus5\ConEmu.exe /icon "%CMDER_ROOT%\cmder.exe" /title Cmder /loadcfgfile "%CMDER_ROOT%\config\ConEmu.xml" /cmd cmd /k "**name_of_a_second_bat_file_on_the_this_same_folder_this**"`
Most helpful comment
Hi,
For start cmder with specified command on windows, create one file .bat with the following content:
then call this .bat with your command:
I hope this helps you :)