conemu - on startup open two windows and position them like i want - conemu

I don't know if that's possible.
I managed to have conemu open two tabs (with a custom name) on startup and cd inside the folders i needs, now my question is:
Is there any way to make conemu open two different tabs in two different windows and position them top-right-corner and bottom-right-corner?
The task i run on startup is the following:
title Website & cmd /k "%ConEmuDir%..\init.bat" && cd c:\src\www
title Other& cmd /k "%ConEmuDir%..\init.bat" && cd c:\src\other
Thanks

As always, read the documentation.
Use -new_console to open a separate window, play with tabs normally. Documentation.
If you’re lucky, the author of ConEmu will notice you and help you out better than I can.

Related

Conemu startup with a task opening multiple tabs

Is there a way with conEmu to by default open a number of different tabs?
I saw this page explaining how to do this with splits,
and I realize I can do Ctrl + T, 1, Enter, but I was hoping there was a way to do this automatically!
"%GIT_HOME%\usr\bin\sh.exe" --login -i -cur_console:t:"repo1":C:"%GIT_HOME%\git-bash.exe":d:"%USERPROFILE%\code\repo1"
"%GIT_HOME%\usr\bin\sh.exe" --login -i -new_console:t:"repo2":C:"%GIT_HOME%\git-bash.exe":d:"%USERPROFILE%\code\repo2"
"%GIT_HOME%\usr\bin\sh.exe" --login -i -new_console:t:"repo3":C:"%GIT_HOME%\git-bash.exe":d:"%USERPROFILE%\code\repo3"
Yes, it is possible but not via the settings Dialog of Conemu. You need a small config file
Create Config File
Go to Conemu installation directory (like C:\Program Files\ConEmu)
Create file startup.txt
List the consoles you want to open at startup. For example
>C:\Program Files\staab\Git\bin\bash.exe
>C:\WINDOWS\system32\cmd.exe
will open Git Bash and cmd at startup (in that order). If you want to set the startup directories for each console you can do this too:
>C:\Program Files\staab\Git\bin\bash.exe -new_console:d:C:\example\path
>C:\WINDOWS\system32\cmd.exe -new_console:d:C:\other\path
Start Conemu with that config file
Create a new desktop shortcut for the ConEmu64.exe (or ConEmu.exe if you use the 32-Bit version)
Right click > Properties on that shortcut.
Add /cmd #startup.txt to the target
Now you can link that shortcut to your task bar or put it in the autostart folder of your computer to start Conemu with those consoles right after login.
Update 1: Name for Tab
I just found out that you can also set the name of all the tabs on startup :-)
>C:\Program Files\staab\Git\bin\bash.exe -new_console:d:C:\example\path -cur_console:t:NAME_OF_TAB
Update 2: Admin Rights
And this is how you give admin rights to the tabs of your choice:
>C:\Program Files\staab\Git\bin\bash.exe -new_console:d:C:\example\path -new_console:a
Don't use this more than necessary, because you have to confirm admin rights for each window individually.

Open multiple Microsoft Edge windows from batch file

I need to open 2 Edge windows from a batch file (not two tabs, 2 windows). I know I can launch edge using the following command:
start microsoft-edge:
But if I try it twice the second command does nothing. If I try it with URLs I get 2 tabs in the same window. e.g.
start microsoft-edge:http://google.com
start microsoft-edge:http://bing.com
Any ideas how to get 2 separate windows?
Use --new-window option:
start msedge http://google.com
start msedge --new-window http://bing.com
As you are aware, you can trigger Microsoft Edge indirectly from the command line (or a batch file) by using the microsoft-edge: protocol handler. Unfortunately, this approach doesn't enable you to open up an arbitrary number of windows.
The Microsoft Edge team built a small utility to assist, and presently hosts it on GitHub.
> MicrosoftEdgeLauncher.exe http://bing.com
> MicrosoftEdgeLauncher.exe http://stackoverflow.com
I just tested this, and it opened two individual windows for me. There does appear to be an issue where the second window doesn't navigate to the URL; remaining open with the New Tab Page.
You can open as many as you like, just create batch files that call other batch files.
Very easy to do.
Ex: batch1.cmd:
#echo off
start microsoft-edge:http://google.com
start "path\batch2.cmd"
exit
Make sure to add "start microsoft-edge:http://bing.com" on your "batch2.cmd" file
Manny
You can use the executable msedge_proxy.exe which is installed alongside msedge.exe. For example in "C:\Program Files (x86)\Microsoft\Edge\Application".
Sample usage:
> msedge_proxy.exe --app=http://bing.com
If you execute that command multiple times, it pops a new window each time.

Is there a way to run vcvars32.bat every time I start a cmd?

I'm using cl in cmd and having to run vcvars32.bat every time I open a cmd window is really a pain in the axx. Can anyone offer a way of running it automatically?
From cmd /?:
If /D was NOT specified on the command line, then when CMD.EXE starts, it
looks for the following REG_SZ/REG_EXPAND_SZ registry variables, and if
either or both are present, they are executed first.
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
and/or
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
You therefore could add vcvars32.bat to one of those AutoRun registry values to have it executed for every cmd.exe instance (except when /D is explicitly specified, of course).
However, be forewarned that doing this could result in other weird side-effects (for example, it could cause other .bat/.cmd scripts to be run in an environment that they aren't expecting).
A workaround that works for some people is to write a batch file and call it A.BAT and make a.bat launch vcvars32.bat. Put a.bat on the path and then it's a matter of opening the cmd prompt and typing a and enter and voila, you're set!
way old, but the easiest way to do this with, say, a shortcut created on your TaskBar is to modify your shortcut (in %appdata%\microsoft\internet explorer\quick launch\user pinned\taskbar, or thereabouts) so the target is:
%windir%\system32\cmd.exe /k vcvars32.cmd
that'll do exactly what you're looking for. The /k tells it to execute the string but keep the window open (string being your batch file). You can either put vcvars32 somewhere in your path, or specify the whole path to vcvars32.
You can use the script in http://www.alteridem.net/2010/09/02/visual-studio-2010-command-prompt-here to make it so when you right-click a folder in explorer the option shows up. After downloading and extracting the zip file you can modify the .inf to point to the correct path to your particular VS version (and change the displayed name if desired). Note the comment on the page about having to rename the file if you are running 64-bit Windows.

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

Run batch file in the background

I have a batch file, this batch file will not start automatically, it will only run when i double click on it.
Can I run the batch file in the background when I double click on it.
Well, you can start it minimized with start, if that is enough. Really hiding it is difficult (although I can think of an option right now).
Basically you need to determine whether the batch has been started by double-clicking it. You can do this by defining a special variable and look for it:
#echo off
if not defined FOO (
set FOO=1
start /min "" %~0
exit /b
)
rem here whatever you wanted to do originally in the batch
As long as the FOO variable isn't defined (which is probably the default almost everywhere), this batch will launch itself minimized again, but with the variable defined first. Environments are passed to subprocesses, which is why this works.
you would generally need something else to run the script in that manor
i.e.
Create a shortcut, and set the “Run” field for the shortcut to “Minimized’.
Once you click or tab away from the cmd.exe window that the batch file is running it, it's "in the background" -- I'm not really sure what you want but it sounds like you might be asking how to run the batch file without displaying the cmd.exe window.
If so I can think of two ways: first, you can create a shortcut to the batch file, right click it, and in the properties there set the shortcut to run minimized (should be a drop down option next to Run).
You can also wrap invocation of the batch file in a VBScript file using Windows Script Host's shell object (calling the Run method) to run the batch file invisibly. Passing 0 as the intWindowStyle parameter will suppress display of a window or anything.
#Ghyath Serhal
I have used cmdow to do this on another program, it is an external application that can be used to modify the command prompt. To use it, you will need to either enter this code (see below) into it's own batch file, or into the command prompt, where it will run 'BatchFile.bat' with a hidden terminal window. I haven't found a way to use this in a single batch file, but I only found out about this today.
cmdow /run /hid 'BatchFile.bat'
Hope this helps.

Resources