Bring focus to a batch started browser window - windows

I have a batch script that launches two Chrome windows. I want to focus the first one when it launches and then the second one.
"%PROGRAMFILES(x86)%\google\chrome\application\chrome.exe" --start-fullscreen --app=https://www.youtube.com/login
//focus this window
...
"%PROGRAMFILES(x86)%\google\chrome\application\chrome.exe" --start-fullscreen --https://www.youtube.com/feed/subscriptions
//focus this window
...
I want to be able to run this in a cmd context, so a powershell or batch script would be great.

Related

START command only opens new window if .EXE is NOT already running

So my Batch file command goes as follows:
#ECHO OFF
SET link1=google.com
SET link2=google.com
SET link3=google.com
START /MAX vivaldi.exe %link1% %link2% %link3%
When I double click my .BAT file, it only opens a new vivaldi window if there isn't one currently running. If I already have a vivaldi window open it will simply just open links 1-3 in new tabs on top of the tabs I already have open(and maximize the window if it is not). I was under the impression that the START command should always open the .EXE in a new window unless the /B flag is set(which it is not)?
Replace your last line with:
START /MAX vivaldi.exe --user-data-dir=c:\temp %link1% %link2% %link3%
You could create a dedicated folder rather than use C:\temp, and specify the full path to that instead.
Inspiration for the use of --user-data-dir from https://superuser.com/a/457045/122072.

Closing a new console window started from a batch script prompts to terminate the script

I'm trying to make a batch script for running multiple command line antivirus scans in a specific order.
I use it this way:
echo Running Sophos virus scan...
start "Sophos Scan" /wait /d "%~dp0sophos" SVRTcli.exe -yes >>%~dp0logs\sophoslog.txt
This will popup a new console window running sophos and wait till it's done.
If I close the new console window, the main window of my batch file will prompt for terminating the batch script. I want to avoid it and just automatically continue with my next command which is similar to the previous (different anti virus engine).
Is it possible? I tried with various solutions on the net. Every time it's the same result. You close the new console and it comes up on your batch cmd.

Running a .bat file continuously opens new instances of CMD?

Trying to run a basic .bat file on my work machine. I have a file named chrome.bat that contains only the line start chrome. When I enter start chrome into CMD or PowerShell, it opens a new window of Chrome as one would expect. When I click on the .bat file, however, new instances of CMD are continuously created, no Chrome window is opened, and I have to hold CTRL-C until the process is killed.
Any insight?
Figured it out. The problem is that I named the file with the same name as the command. Renaming the file to blah.bat works just fine.

Hide CMD window after execute command line by the RUN

How to hide CMD/BAT (the black box) WITHOUT using Vbscript, I dont like using VBSCRIPT because it slows down application before it autorun. So if you have a code to put into batch or CMD to hide the CMD/Bat file WITHOUT using VBScrpit. please let me know.
thanks
This might help you:
Solution #1
Use the /min slash after START command when starting your bat-file. This will start it with a minimized window. Example:
START /min c:\mypath\mybatfile.bat
Solution #2
Create a shortcut to CMD.EXE. Open up Properties box of the shortcut.
In shortcut-tab change "run" to "minimized".
In the target address (path and name of CMD) append path and name of your bat-file.
If you now doubleclick the shortcut, it should run CMD minimized, with no window showing, which in turn should start your bat-file.

Keep Windows command window open

I'm running a command through the Windows shell- an existing command window (cmd.exe). When I execute the command, the window closes, even though it's a freestanding window not tied to the command.
How can I keep the window open to see the output?
You can't simply start a child cmd session because it'll share same window and if your custom tool actively closes its window (I wonder why) then it'll close your console and output will disappear.
There isn't much you can do if a program want to close console window but you can at least save its output to a file (to be inspected later with type). If you're working with that console and you don't want to close it then you can use start cmd to execute it in a new console window. Like this:
start cmd /c tool -args ^> output.txt
tool output will be available in output.txt after it finished.
It appears that the executable is closing the command window. Here is what you could try, may work. open a command shell. In the shell issue "cmd" and open another command shell. Run your executable in the newly opened command shell. You nested cmd will be exited, but you may still be able to see some of the output of your executable.

Resources