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

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

Related

Run a different batch file when one coses

I have 2 batch files (1.bat and 2.bat). I want 2.bat to run when 1.bat closes. Is that possible?
Or is there a way to close a batch file when a batch file closes. Here is my code which doesnt work:
cd C:\xampp
start apache_start.bat
cd C:\Users\MinecraftServer\Desktop\1.12.2MinecraftServer
MC1.12.2Start.bat
taskkill /F /IM cmd.exe /T
I have a minecraft server running with a .bat file and a web server running off of a .bat file (using xampp, its used for prtg monitorng).
start will create a completely independent process and continue immediately to your next batch command. That independent process may do a job and terminate, or may say open an application like notepad and wait until the notepad is closed. Regardless, a straight start command will not stop the batch that it is in - the next step will be executed, whether or not the process that has been started has terminated.
You can also add the /wait switch to start. If this switch is used, the batch will wait until the started process terminates.
Preferred syntax for start is
start /wait "window title" executable parameters...
where "window title" may be an empty, but not absent string. Including this as the first parameter is preferred because the first quoted string in a start command is used as a window title for the started process, and thus start may not act as expected where the executable or any of its parameters is quoted.
call executablename... will wait for that executable to terminate before progressing to the next step. This may or may not be what is desired.
MC1.12.2Start.bat in your code will SWITCH to that batch and remaining batch lines will be ignored.
Which may be fortunate in this case, since as you've coded it, the apache_start.bat may or may not have completed when the taskkill command is run, killing all cmd.exe sessions.

kill a batch file that is stuck from another cmd box

Hope I'm in the right place here, wasn't sure where to post and this seemed the most likely
I use a cmd box to run a serial flasher program for repairing wifi boards, the way it works is this.
open a command prompt and change to the working directory
enter the command
sfh_DM36x.exe -nandflash -v -p "COM3"
this starts the flashing program, however, due to the way it works, the program when finishing the first time just loops with bootme bootme, this is normal behavior.
Normally I just hit CTRL+C and exit the batch file.
The same command is run again and this time the flashing process completes and you are returned to the C:\ prompt.
Now you have the information here is what I am trying to achieve.
Launch a batch file that runs the runflash.bat, kill the runflash.bat and then run runflash.bat again.
So far I have gotten as far as this (start.bat)
start c:\users\jud\desktop\runflash.bat
timeout /t 5
This runs a new CMD prompt and opens the runflash.bat
I've then entered a timeout of 5 seconds (long enough for the first attempt to finish)
at this point, I wanted to kill the currently open CMD prompt and then execute runflash.bat again.
at this point I'm stumped, any attempt to kill the second CMD prompt just kills the original, I've looked at taskkill but the PID changes each time I run the script, as well as other suggestions I've come across during google searches, most just relate to killing batch files manually or killing a CMD prompt where a batch file has finished.
Can this be done, the idea is to pass the file out to users who aren't familiar with CMD prompt workings as an all in one solution.
Provide the new process with a unique title (see start /? - the first quoted parameter is set as a title). Takskkill can then identify and close the process with its title:
start "JudRunFlash" "c:\users\jud\desktop\runflash.bat"
timeout /t 5 >nul
taskkill /fi "WindowTitle eq JudRunFlash"

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.

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.

Resources