Batch file help. Needing to position windows.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
YukoValis
Posts: 22
Joined: 08 Jan 2019 12:43

Batch file help. Needing to position windows.

#1 Post by YukoValis » 08 Jan 2019 12:52

I've created a few simple batch files for work. One of my job functions means I need to constantly check switches and servers at various stores. So when a store calls with a problem, I need to ping around 6 different things constantly.
So my batch file is a simple, which just leads to a bunch of this after checking a variable I added beforehand.
start cmd /k ping xxx.xxx.yyy.xxx -t
start cmd /k ping xxx.xxx.yyy.xxx -t
start cmd /k ping xxx.xxx.yyy.xxx -t

My issue is that it opens all of these windows on top of each other. I was wondering if there is some way to tell each to open on a specific area of my screen? Or just not on top of each other?
Like am I able to set coordinates for each start maybe?

Please note. I'm trying to share these with my co-workers (with my bosses permission of course) so the fix can't be something as simple as messing with the settings or installing programs.
Thank you for your time.
Last edited by YukoValis on 11 Jan 2019 16:48, edited 2 times in total.

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Batch file help. Needing to position windows.

#2 Post by ShadowThief » 08 Jan 2019 19:53

Check out this topic: viewtopic.php?f=3&t=8033

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Batch file help. Needing to position windows.

#3 Post by Ed Dyreen » 09 Jan 2019 04:25

cmdow is a 32bit app which can do that too.

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Batch file help. Needing to position windows.

#4 Post by Aacini » 09 Jan 2019 10:24

... and also my Window.exe auxiliary .exe program, that is much smaller...

Antonio

YukoValis
Posts: 22
Joined: 08 Jan 2019 12:43

Re: Batch file help. Needing to position windows.

#5 Post by YukoValis » 09 Jan 2019 14:51

So in other words.. not without great difficulty. People talk there of making scripts to open scripts and pull from the registry to make things happen. Shame there isn't like a simple "start position (y.x) cmd" etc.

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Batch file help. Needing to position windows.

#6 Post by Aacini » 10 Jan 2019 15:00

A simple way? What about this one?

Code: Select all

Window GPos x y
The Window.exe file is 4096 bytes size, that is 4 KB, and it can be created from a Batch file in a very simple way...

Antonio

YukoValis
Posts: 22
Joined: 08 Jan 2019 12:43

Re: Batch file help. Needing to position windows.

#7 Post by YukoValis » 11 Jan 2019 12:45

Aacini wrote:
10 Jan 2019 15:00
A simple way? What about this one?

Code: Select all

Window GPos x y
The Window.exe file is 4096 bytes size, that is 4 KB, and it can be created from a Batch file in a very simple way...

Antonio
That didn't seem to work. How would I use that? Just put it in the line after the start? I tried it in-between the lines, in the lines. Is that the right syntax?
I'm trying to open these three windows in different positions on my screen.
start cmd /k ping xxx.xxx.yyy.xxx -t
start cmd /k ping xxx.xxx.yyy.xxx -t
start cmd /k ping xxx.xxx.yyy.xxx -t

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Batch file help. Needing to position windows.

#8 Post by aGerman » 11 Jan 2019 13:04

Like that:

Code: Select all

start cmd /k "Window GPos 100 50 & ping xxx.xxx.yyy.xxx -t"
Where Window.exe should be in the same directory along with your batch script (otherwise you have to define the path, too). The 100 is an example for the distance from the left edge, and 50 for the distance from the top edge of your screen.

Steffen

YukoValis
Posts: 22
Joined: 08 Jan 2019 12:43

Re: Batch file help. Needing to position windows.

#9 Post by YukoValis » 11 Jan 2019 14:44

I'm trying really hard to understand. I do appreciate your help. So I need to create a window.exe file in the batch, and that will somehow allow me to change the position of the cmd windows I'm opening, then I guess I have the batch delete the window.exe? Do I have to create and delete for every cmd window that gets opened?

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Batch file help. Needing to position windows.

#10 Post by aGerman » 11 Jan 2019 16:31

Window.exe is a tool that you'll find if you follow the link Aacini provided. It's in the .ZIP file you can download in the linked thread, and it's already the compiled program that you can use instantly. No need to create it new every time you need it.

Steffen

YukoValis
Posts: 22
Joined: 08 Jan 2019 12:43

Re: Batch file help. Needing to position windows.

#11 Post by YukoValis » 11 Jan 2019 16:46

aGerman wrote:
11 Jan 2019 16:31
Window.exe is a tool that you'll find if you follow the link Aacini provided. It's in the .ZIP file you can download in the linked thread, and it's already the compiled program that you can use instantly. No need to create it new every time you need it.

Steffen
Man... you got my hopes up. So once again I point out it isn't something that can easily be done. If you read the last line of my OP, I explain I can't change settings or download programs. I am trying to figure out if it is possible to do in the code itself.

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Batch file help. Needing to position windows.

#12 Post by ShadowThief » 11 Jan 2019 17:34

Does embedding the program in the script as base64 count as downloading it? (My work has a similar policy, so I'm guessing it does.)

I know the Powershell looks like a lot, but the vast majority of it is just setting stuff up to make it work.

YukoValis
Posts: 22
Joined: 08 Jan 2019 12:43

Re: Batch file help. Needing to position windows.

#13 Post by YukoValis » 11 Jan 2019 18:10

ShadowThief wrote:
11 Jan 2019 17:34
Does embedding the program in the script as base64 count as downloading it? (My work has a similar policy, so I'm guessing it does.)

I know the Powershell looks like a lot, but the vast majority of it is just setting stuff up to make it work.
Putting the program or writing the program in the script would work. I don't know how to do any of that, but it would. I just can't download any kind of files or applications to make it work.
Like I need to write something I could just send to someone by itself, and have it work. I was hoping there was just a quick positioning line I could add, but that doesn't seem to be the case : (

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Batch file help. Needing to position windows.

#14 Post by aGerman » 11 Jan 2019 18:39

Try if something like this hybrid script works for you

Code: Select all

@if (@a)==(@b) @end /*
@echo off &setlocal
set "start=cscript //nologo //e:jscript %~fs0 "

::                                    columns   lines             target               left  top 
%start% "cmd /s /q /d /k ^"^"mode con cols=60 lines=20 ^& ping 172.217.17.142 -t ^"^""    0    0
%start% "cmd /s /q /d /k ^"^"mode con cols=60 lines=20 ^& ping google.com     -t ^"^""  500    0
%start% "cmd /s /q /d /k ^"^"mode con cols=60 lines=20 ^& ping localhost      -t ^"^"" 1000    0


goto :eof */
var objWMIService = GetObject('winmgmts:\\\\.\\root\\CIMV2'),
    objProcess = objWMIService.Get('Win32_Process'),
    objParam = objProcess.Methods_('Create').InParameters.SpawnInstance_(),
    objStartup = objWMIService.Get('Win32_ProcessStartup').SpawnInstance_();
objStartup.X = WScript.Arguments(1);
objStartup.Y = WScript.Arguments(2);
objParam.Properties_.Item('CommandLine').Value = WScript.Arguments(0);
objParam.Properties_.Item('ProcessStartupInformation').Value = objStartup;
objWMIService.ExecMethod('Win32_Process', 'Create', objParam);
Steffen

YukoValis
Posts: 22
Joined: 08 Jan 2019 12:43

Re: Batch file help. Needing to position windows.

#15 Post by YukoValis » 12 Jan 2019 18:34

aGerman wrote:
11 Jan 2019 18:39
Try if something like this hybrid script works for you
How the heck did you get that good? Like seriously.. that is exactly what I needed. I barely had to adjust it to fit, and I am in awe. Thank you. Seriously if there is anything I can do please let me know to make it up to you.

Post Reply