Page 1 of 2

Batch file help. Needing to position windows.

Posted: 08 Jan 2019 12:52
by YukoValis
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.

Re: Batch file help. Needing to position windows.

Posted: 08 Jan 2019 19:53
by ShadowThief
Check out this topic: viewtopic.php?f=3&t=8033

Re: Batch file help. Needing to position windows.

Posted: 09 Jan 2019 04:25
by Ed Dyreen
cmdow is a 32bit app which can do that too.

Re: Batch file help. Needing to position windows.

Posted: 09 Jan 2019 10:24
by Aacini
... and also my Window.exe auxiliary .exe program, that is much smaller...

Antonio

Re: Batch file help. Needing to position windows.

Posted: 09 Jan 2019 14:51
by YukoValis
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.

Re: Batch file help. Needing to position windows.

Posted: 10 Jan 2019 15:00
by Aacini
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

Re: Batch file help. Needing to position windows.

Posted: 11 Jan 2019 12:45
by YukoValis
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

Re: Batch file help. Needing to position windows.

Posted: 11 Jan 2019 13:04
by aGerman
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

Re: Batch file help. Needing to position windows.

Posted: 11 Jan 2019 14:44
by YukoValis
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?

Re: Batch file help. Needing to position windows.

Posted: 11 Jan 2019 16:31
by aGerman
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

Re: Batch file help. Needing to position windows.

Posted: 11 Jan 2019 16:46
by YukoValis
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.

Re: Batch file help. Needing to position windows.

Posted: 11 Jan 2019 17:34
by ShadowThief
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.

Re: Batch file help. Needing to position windows.

Posted: 11 Jan 2019 18:10
by YukoValis
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 : (

Re: Batch file help. Needing to position windows.

Posted: 11 Jan 2019 18:39
by aGerman
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

Re: Batch file help. Needing to position windows.

Posted: 12 Jan 2019 18:34
by YukoValis
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.