Batch file help. Needing to position windows.
Moderator: DosItHelp
Batch file help. Needing to position windows.
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.
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.
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Batch file help. Needing to position windows.
Check out this topic: viewtopic.php?f=3&t=8033
Re: Batch file help. Needing to position windows.
cmdow is a 32bit app which can do that too.
Re: Batch file help. Needing to position windows.
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.
A simple way? What about this one?
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
Code: Select all
Window GPos x y
Antonio
Re: Batch file help. Needing to position windows.
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?Aacini wrote: ↑10 Jan 2019 15:00A simple way? What about this one?
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...Code: Select all
Window GPos x y
Antonio
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.
Like that:
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
Code: Select all
start cmd /k "Window GPos 100 50 & ping xxx.xxx.yyy.xxx -t"
Steffen
Re: Batch file help. Needing to position windows.
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.
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
Steffen
Re: Batch file help. Needing to position windows.
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.
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Batch file help. Needing to position windows.
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.
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.
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.ShadowThief wrote: ↑11 Jan 2019 17:34Does 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.
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.
Try if something like this hybrid script works for you
Steffen
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);
Re: Batch file help. Needing to position windows.
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.