ConEmu commands in task - batch-file

I'm trying to get a Task in ConEmu to open several consoles, and for each run a batch-like script when opened. For example:
Open a Git Bash, name the console "X", set the current directory to "Y".
Open another Git Bash and run a set of commands, for example "cd A/B/C", "vagrant up"
Open a regular command window, run the command "cd D/E/F", "grunt watch"
I want the second and third consoles to appear alongside each other, but underneath the first console. So far I am stuck getting commands to run; I have a task that runs the following:
"%ProgramFiles(x86)%\Git\bin\sh.exe" --login -i "-cur_console:n:t:Git Bash" "-cur_console:d:C:\Users\Ole Vik\dev"
"%ProgramFiles(x86)%\Git\bin\sh.exe" --login -i "-cur_console:s1TVn:t:Vagrant"
cmd "-cur_console:s2THn:t:Third"
Reading the ConEmu wiki led me to the new_console and cur_console switches, but I'm having trouble figuring out if I can somehow enter commands in the Task setup, or maybe if I can have it run a .bat script on each console.

No colon is needed between switches (n & t for example).
cmd has /k switch to run commands.
I don't know the way to tell bash "run this command and stay in prompt". May be you need to run commands with &. I'm not sure about second line, you need to check it yourself.
"%ProgramFiles(x86)%\Git\bin\sh.exe" --login -i "-cur_console:nt:Git Bash" "-cur_console:d:C:\Users\Ole Vik\dev"
cmd -cur_console:s1TVnt:Vagrant /c vagrant up & "%ProgramFiles(x86)%\Git\bin\sh.exe" --login -i"
cmd -cur_console:s2THnt:Third /k cd /d "D\E\F" & grunt watch

Related

Windows 10 - Automatically exit batch script

This is my script:
SQLPLUS -S -M "HTML ON TABLE 'BORDER="2"'" username/pass#env #test.sql>test.html
After execution command prompt window stays open. How do I auto-close?
After your line of code add another line, like this:
exit
or
tskill cmd.exe
I hope I can help you.

Creating a cmd line shortcut

I am completely new to Windows, as i am an OSX user.
I am having to run a task in the cmd line every day, is there any way i can create a shortcut on my desktop which automates this?
Task example, open cmd, then execute:
atomInstaller npm -view -Xmx8g -Xms3g
Thanks
You could just make a shortcut to cmd.exe and add command line switches:
https://superuser.com/questions/358565/adding-command-line-switches-to-windows-shortcuts
Or you can put commands into a batch file using notepad ( or a better text editor ):
#echo off
atomInstaller npm -view -Xmx8g -Xms3g
save it as npm.bat then double-click it..
You can use shortcutjs.bat:
call shortcutjs.bat -linkfile "%userprofile%\desktop\atominstaller.lnk" -target "C:\atomInstaller.bat" -adminpermissions yes -iconlocation "C:\Windows\System32\compstui.dll,3" -hotkey "Ctrl+Shift+M"
Here's the usage:
shortcutjs.bat -linkfile link -target target [-linkarguments linkarguments] [-description description] [-iconlocation iconlocation] [-hotkey hotkey] [-windowstyle 1|3|7] [-workingdirectory workingdirectory] [-adminpermissions yes|no]
You can add additional parameter with -linkarguments or start location with -workingdirectory

Batch for loop in psexec command

I'm trying to use a batch FOR loop inside a psexec. I need to make a script that offers me the possibility to choose the subfolders (I store the items in %list_of_items%) in %local_folder% that are needed to be copied with ncftpput on remote server. I cannot put the entire psexec inside the loop because I dont want to insert every time the password.
The piece of code:
psexec \\remote_server -u DOMAIN\user cmd /c FOR %%i IN "%list_of_items%" DO ("ncftpput -f c:\folders\file_with_creds.cfg -R remote_folder/ %local_folder%/%%i")
Example
I have:
%local_folder%\folder111
%local_folder%\folder222
%local_folder%\folder333
I choose to copy the items folder111 and folder333 so I store them in %list_of_items%. For every item in the list I need to run ncftpput to transfer to remote server the folder but doesnt work....
The error:
"folder111" was unexpected at this time.
cmd exited on remote_server with error code 1.
Can you help me please to find what I'm doing wrong?
Thank you.

execute command inside cmd application with one command

I installed Linphone application
http://www.linphone.org/technical-corner/linphone/documentation
I am running this application via cmd executing this command
"C:\Program Files (x86)\Linphone\bin\linphonec.exe"
then I make the call through this command
call number#x.x.x.x
I want to join the tow commands in one line so the cmd start the linphone then execute the call command inside the linphone
Output with & operator
C:\Users\Desktop\1>CD "C:\Program Files (x86)\Linphone\bin\"
C:\Program Files (x86)\Linphone\bin>linphonec.exe & call number#x.x.x.x
WARNING: no real random source present!
Ready
Warning: video is disabled in linphonec, use -V or -C or -D to enable.
linphonec>
how i can do that in cmd ?
CD C:\Program Files (x86)\Linphone\bin\
echo call number#x.x.x.x|linphonec.exe
may work.

How to hold ConEmu window from exiting?

Gurus
I am using using ConEmu command line to run a shell script in ConEmu. However ConEmu always exits after the script completes. Is there any way to make ConEmu work like "mintty -h always" which keeps the Window open?
ConEMU CLI:
ConEMU.exe /cmd C:\mybin\sh.exe my_script.sh
I wish it holds window like:
mintty.exe -h always -e C:\mybin\bash.exe my_script.sh
Thanks
You may use following syntax
ConEmu.exe /cmd C:\mybin\sh.exe my_script.sh -cur_console:c

Resources