CMD command in Windows to switch to an already open application
Solution 1:
How do I switch to an already open application from the command line?
You can use nircmd from nirsoft to do this.
Example:
nircmd win activate title "Calculator"
Notes:
- See NirCmd Command Reference - win
What is nircmd?
NirCmd is a small command-line utility that allows you to do some useful tasks without displaying any user interface. By running NirCmd with simple command-line option, you can write and delete values and keys in the Registry, write values into INI file, dial to your internet account or connect to a VPN network, restart windows or shut down the computer, create shortcut to a file, change the created/modified date of a file, change your display settings, turn off your monitor, open the door of your CD-ROM drive, and more...
Source nircmd
Disclaimer
I am not affiliated with nirsoft in any way, I am just an end user of the software.
Solution 2:
The solution with 1 line of initialisation and 1 line calling. The calling is %tmp%\switch.vbs ...
used twice below.
Title %vTitle%
:: preparation (initialisation)
@echo WScript.CreateObject("WScript.Shell").AppActivate(WScript.Arguments.Item(0))>%tmp%\switch.vbs
:: some cmd lines exposing other windows
:: ...
:: just as an example to start the notepad
start "" notepad
:: use 1: focus back on this cmd window
%tmp%\switch.vbs %vTitle%
:: ...
:: use 2: focus to an application with <application name>
%tmp%\switch.vbs "<application name>"