Hi
I have a script that opens 4 x CMD windows and carries out ping, telnet and tracert. When these windows open they open on top of each other. I am looking for a way to position the 4 x CMD windows at each corner of the monitor screen. Is this possible, do i need to add something to the script below.
@echo off
start " ping " 10.0.1.20
start " ping " 8.8.8.8
start " telnet " google.com 443
start " tracert " google.com
Open multiple CMD windows running pings, tracert etc and position them on screen
Moderator: DosItHelp
Re: Open multiple CMD windows running pings, tracert etc and position them on screen
There is no way to do that in Batch only. I remember a few snippets I wrote for this purpose where Batch calls PowerShell which contains C# code that wraps the Win32 API ... Sounds like a mess and is a mess.
viewtopic.php?f=3&t=8822
viewtopic.php?f=3&t=10439&p=66692#p66682
viewtopic.php?f=3&t=10552&p=67679#p67679
... and a couple more.
That's all quite obsolet because now that even Win 8.1 is a walking dead for almost two years, I assume you're running at least Win 10 where you can use the Windows Terminal. Just run it with the commands executed in another pane of the same tab each.
Steffen
viewtopic.php?f=3&t=8822
viewtopic.php?f=3&t=10439&p=66692#p66682
viewtopic.php?f=3&t=10552&p=67679#p67679
... and a couple more.
That's all quite obsolet because now that even Win 8.1 is a walking dead for almost two years, I assume you're running at least Win 10 where you can use the Windows Terminal. Just run it with the commands executed in another pane of the same tab each.
Code: Select all
@echo off
start wt -M ^
-p "Command Prompt" --suppressApplicationTitle --title "10.0.1.20" cmd /k "ping /t 10.0.1.20" ;^
sp -V -p "Command Prompt" --suppressApplicationTitle --title "8.8.8.8" cmd /k "ping /t 8.8.8.8" ;^
sp -H -p "Command Prompt" --suppressApplicationTitle --title "google.com 443%" cmd /k "telnet google.com 443" ;^
mf first ;^
sp -H -p "Command Prompt" --suppressApplicationTitle --title "google.com" cmd /k "tracert google.com"
- Attachments
-
- panes.png (1.28 MiB) Viewed 11863 times
Re: Open multiple CMD windows running pings, tracert etc and position them on screen
Some time ago I developed a series of Auxiliary .exe programs as aid for Batch files. One of those programs is Window.exe that allows to manage cmd.exe windows in several ways; for example, to position the window at any place in the screen. The Batch file below solve this problem using Window.exe auxiliary program:
Antonio
Code: Select all
@echo off
setlocal
rem Window.exe example - Distribute 4 cmd.exe windows in the screen
rem Download Window.exe auxiliary program from:
rem https://www.dostips.com/forum/viewtopic.php?f=3&t=3428
rem Get screen size and calculate cmd.exe windows sizes and positions
Window GSize MAX
Window GSize
set /A "posX=(%errorlevel%&0xFFFF)/2+5, posY=(%errorlevel%>>16)/2+10"
Window Size
set /A "cols=(%errorlevel%&0xFFFF)/2, lines=(%errorlevel%>>16)/2-5"
rem Start each one of the four cmd.exe windows
set "PROMPT=$P$_$G"
start "ping 10.0.1.20" cmd.exe /K mode %cols%,%lines% ^& Window GPos=0,5 ^& ping /t 10.0.1.20
start "ping 8.8.8.8" cmd.exe /K mode %cols%,%lines% ^& Window GPos=%posX%,5 ^& ping /t 8.8.8.8
start "telnet google.com" cmd.exe /K mode %cols%,%lines% ^& Window GPos=0,%posY% ^& telnet google.com 443
start "tracert google.com" cmd.exe /K mode %cols%,%lines% ^& Window GPos=%posX%,%posY% ^& tracert google.com
Antonio