Setup cmd.exe parameter when starting ConEmu - conemu

I have some configuration setting in config.bat, I can manually execute it using cmd.exe /k "%HOMEDRIVE%%HOMEPATH%\config.bat"
How can I setup ConEmu to execute cmd.exe with parameters ?
I tried to put the cmd.exe + parameters in the Task parameters.. and Commands (application, argument).., but neither of them is working.
Please help, thanks.

You missed it just by a inch :-)
Simply put the cmd /k <path>\<to>\<your>\config.bat in the Commands text area.
(sorry I can not post images yet)

Related

Jenkins job stuck after command start

I have a problem in my jenkins job and I isolated into one command. So I created another separate job to try to fix it.
So in this job, called "teste" I only have one single command:
start cmd /k call "C:\Program Files\myDir\myBat.bat"
This opens a separate cmd window running my bat file, which should keep running "forever".
But the problem is when I do it, my jenkins job keeps stuck into a "exit 0" operation that I have no idea from where it came from.
Thats the console:
[EnvInject] - Loading node environment variables.
Building remotely on Machine01 in workspace C:\workspace\teste
[teste] $ cmd /c call C:\...dir\jenkins.bat
C:\workspace\teste>start cmd /k call "C:\Program Files\myDir\myBat.bat"
C:\workspace\teste>exit 0
Then it keep stuck at that point.
Example of myBat.bat content:
echo hi
pause
There's any way to make this call in another window without waiting for its finish?
I solve my problem changing the way I was calling my other .bat, calling it through powershell. But since I was from a bat file, I used the command to send a powershell command, calling my other bat file.
Also, I've added another line changing the jenkins BUILD_ID to a fake one, so it doesn't kill it.
So I changed from this line:
start cmd /k call "C:\Program Files\myDir\myBat.bat"
To this :
set BUILD_ID=dontKillMe
powershell -Command "Start-Process 'C:\Program Files\myDir\myBat.bat'"
I hope it helps someone someday.

conemu - how to 'group input' in a task?

I have created a task in conemu which launches 3 consoles and ssh to 3 different servers. I would like to also 'group inputs' directly when launching this new task.
Right now, I need to press Apps+G once the 3 consoles are up in order to be able to run the same command in all three consoles.
Is there a way to get Apps+G to be called when launching the task without I having to do it ?
Supposing you start three cmd.exe consoles. First one would be active. Last line executes GuiMacro and immediately terminates.
>cmd.exe /k "%ConEmuBaseDir%\CmdInit.cmd"
cmd.exe /k "%ConEmuBaseDir%\CmdInit.cmd"
cmd.exe /k "%ConEmuBaseDir%\CmdInit.cmd"
cmd /c -cur_console:n ConEmuC -GuiMacro GroupInput 4

How to execute multiple commands from a batch file, in windows command prompt, while keeping the command prompt context open?

I want to create a batch file that would execute two commands one after the other, and then keep the CMD window open. The following is what I tried, after some searching on the internet, but only the first command is getting executed.
What am I missing?
cmd /k C:\Users\Hp\yolo\test1\.env1\Scripts\activate && cd C:\Users\Hp\yolo\test2
I also tried with just one '&' instead of two, but that doesn't work either. Only the first command gets executed in both cases.
doskey /macrofile=%~dp0adb_macros.txt
color 9F
cmd /K
For those who came here for an example of an actual answer

Prevent batch file in CMD from closing without using Pause

Currently I want to run a batch file that fires the command git log and show me that log.
After that I need to be able to commit and view the status so this prompt may not disappear after a key press.
I've searched the net and the only answer people have is pause which close the prompt after a keypress.
Does anyone have the solution for me? Currently I made a shortcut to cmd.exe and made the target my folder, but I want to execute some commands also.
Thanks in advance.
This (below) tested OK in Windows 7. To exit the window it creates, type "exit" when done.
start cmd /K "cd \[the-target-folder] && git log"
Where:
[the-target-folder] you replace with your target folder
Note:
&& lets you run two commands on one line
/K is a parameter to the cmd shell program which which carries out the command specified by string and remains.

Batch file to run a command in cmd within a directory

I want to have a batch file(must be placed on desktop) which does the following;
opens cmd
navigates to a directory, e.g. C:\activiti-5.9\setup
runs a command within the directory, e.g. ant demo.start (this command runs the activiti server)
I tried the following to reach to the directory but how to run command, "ant demo.start"?
START cmd.exe /k "cd C:\activiti-5.9\setup"
Thank you for the help.
EDIT:
Referring to zb226's answer below: One more question if you can answer me is how to make that cmd to be run as administrator? will the following work?
START cmd /K "runas /user:administrator & cd C:\activiti-5.9\setup & ant demo.start"
Chain arbitrary commands using & like this:
command1 & command2 & command3 & ...
Thus, in your particular case, put this line in a batch file on your desktop:
START cmd.exe /k "cd C:\activiti-5.9\setup & ant demo.start"
You can also use && to chain commands, albeit this will perform error checking and the execution chain will break if one of the commands fails. The behaviour is detailed here.
Edit: Intrigued by #James K's comment "You CAN chain the commands, but they will have no effect", I tested some more and to my surprise discovered, that the program I was starting in my original test - firefox.exe - while not existing in a directory in the PATH environment variable, is actually executable anywhere on my system (which really made me wonder - see bottom of answer for explanation). So in fact executing...
START cmd.exe /k "cd C:\progra~1\mozill~1 && firefox"
...didn't prove the solution was working. So I chose another program (nLite) after making sure that it was not executable anywhere on my system:
START cmd.exe /k "cd C:\progra~1\nlite && nlite"
And that works just as my original answer already suggested. A Windows version is not given in the question, but I'm using Windows XP, btw.
If anybody is interested why firefox.exe, while not being in PATH, is executable anywhere on my system - and very probably on yours as well - this is due to a registry key where applications can be registered to be available everywhere. See this SU answer for details.
For me, the following is working and running activiti server as well as opening the explorer in browser (with the help of zb226's answer and comment);
START "runas /user:administrator" cmd /K "cd C:\activiti-5.9\setup & ant demo.start"
START /wait localhost:8080/activiti-explorer
This question is 5 years old. I wonder why still nobody has found the /d switch to set the working folder:
start /d "c:\activiti-5.9\setup" cmd /k ant demo.start
CMD.EXE will not execute internal commands contained inside the string. Only actual files can be launched with that string.
You will need to actually call a batch file to do what you want.
BAT1.bat
start cmd.exe /k bat2.bat
BAT2.bat
cd C:\activiti-5.9\setup
ant demo.start
You may want to create a folder called BAT, and add it's location to your path.
So if you create C:\BAT, add C:\BAT\; to the path. The path is located at:
click -> Start -> right-click Computer -> Properties ->
click -> Avanced System Settings -> Environment Variables
select -> Path (From either list. User Variables are specific to
your profile, System Variables are, duh, system-wide.)
Click -> Edit
Press the -> the [END] or [HOME] key.
Type -> C:\BAT\;
Click -> OK -> OK
Now place all your batch files in C:\BAT and they will be found, regardless of the current directory.
Mine DID execute commands in order. Here's my version of what I was using it for:
START cmd.exe /k "U: & cd U:\Design_stuff\new_lcso_website_2017 & python -m http.server"
I needed to
Change to my U drive
CD to a specific folder containing a website I'm redesigning
Execute python with the http server module (to display the contents in my browser).
If those commands are out of order, it would not display the correct files. I initially forgot to change to U: and, running the batch file on my Desktop, it created a web page in my browser at http://localhost:8000 showing me the contents of my Desktop instead of the folder I wanted.
You Can Also Check It:
cmd /c cd /d C:\activiti-5.9\setup & ant demo.start

Resources