execute command inside cmd application with one command - batch-file

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.

Related

How to execute many commands in 1 batch file using 1 psql?

I'm trying to run a batch file to execute many commands in 1 psql shell
I'm using Postgres version 11.4
This is my code:
#ECHO OFF
"C:\Program Files\PostgreSQL\11\bin\psql.exe" "dbname=databasename
host=hostname user=username password=#bcd1234 port=5432 sslmode=require"
DELETE from my_table1;
DELETE from my_table2;
DELETE from my_table3;
PAUSE
I expect the script delete all data from 3 tables, but it only run the first command line to login Postgres.
You can execute multiple commands by executing them from a file.
Create a file and write all your commands in it.
Use the -f option to pass the file as the source of commands.
Please refer: (-f option) https://www.postgresql.org/docs/9.1/app-psql.html

vboxmanage running a bat file, but doesn't see arguments

I have a Virtualbox instance running Windows10, and am running the following command from outside of VirtualBox:
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe"
--nologo guestcontrol "Win10_x64" run
--exe "\\VBOXSVR\codemodel\VirtualBox_RunInstaller.bat"
--username user --password pass
--wait-stdout
-- VERSION5
The argument I am trying to pass to the VirtualBox_RunInstaller bat file is VERSION5, but %1 is always empty. I can see this because when set version=%1 is run, it prints out set version=. So it is successfully running the batch file, but no arguments are getting passed to it.
Have I got the syntax wrong? I've tried several variations at this point but haven't got it right yet.
If I understand this link correctly the --exe to address is cmd.exe and the batch file has to be the first argument (to the exe)
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" ^
--nologo guestcontrol "Win10_x64" run ^
--exe cmd.exe ^
--username user --password pass ^
--wait-stdout ^
-- "\\VBOXSVR\codemodel\VirtualBox_RunInstaller.bat" VERSION5

ConEmu commands in task

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

.bat file to open executable within Console2

I am aiming to create a .bat launcher that will execute a command line .exe program within Console2.
My best guess would be that it should go something like:
#echo off
start "" Console.exe program.exe
but all that does it open Console2.
Please note that all .bat, and executables are all in the same folder.
Ok I looked in source for the Console.exe and drilled down into the compiled help.
You need a -r
So: Console.exe -r program.exe
Command line parameters
Console supports these command line parameters:
-c <configuration file>
Specifies a configuration file.
-w <main window title>
Sets main window title. This option will override all other main window title settings (e.g. 'use tab titles' setting)
-t <tab name>
Specifies a startup tab. Tab must be defined in Console settings.
-d <directory>
Specifies a startup directory. If you want to parametrize startup dirs, you need to specify startup directory parameter as "%1"\ (backslash is outside of the double quotes)
-r <command>
Specifies a startup shell command.
-ts <sleep time in ms>
Specifies sleep time between starting next tab if multiple -t's are specified.
I'd never heard of this program, but its source code
else if (wstring(argv[i]) == wstring(L"-r"))
{
// startup cmd
++i;
if (i == argc) break;
startupCmds.push_back(argv[i]);
}
makes it seem like you might want to try:
Console.exe -r program.exe

How do I run a .bat file from CMake?

How do I run a .bat file from CMake in a pre-link or a post-build event?
You could use add_custom_command, e.g.
if(WIN32)
add_custom_command(TARGET <Your target>
POST_BUILD
COMMAND cmd //C <path to .bat file> <ARGS> )
endif()
For full details about add_custom_command run
cmake --help-command add_custom_command
The following also works. In case you read or create a file inside the bat script don't forget to specify the exact path inside the bat script.
ADD_CUSTOM_TARGET(
myCustomTarget
COMMAND cmd /c E:/Myfiles/mytxt.bat
)
ADD_DEPENDENCIES(myTarget myCustomTarget)
myTarget will be executed after myCustomTarget.

Resources