Batch file help. Needing to position windows.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

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

Re: Batch file help. Needing to position windows.

#16 Post by aGerman » 13 Jan 2019 05:40

It's basically the VBScript code found there:
viewtopic.php?t=4285
… but translated to JScript. I hoped I would have been able to use the XCountChars and YCountChars members of the Win32_ProcessStartup class to run the CMD process with the window size already adjusted. That didn't work though. I had to use the MODE command wich makes it look rather clumsy with all the escaping of special characters.
Anyway, glad it helped.

Steffen

buythedop
Posts: 3
Joined: 21 Jan 2022 11:41

Re: Batch file help. Needing to position windows.

#17 Post by buythedop » 21 Jan 2022 11:44

Hi, I want to use batch file and open to specific position.

Where would the Window Gpos code fit in here?

Thanks a lot

Code: Select all

@echo off
start "Chrome" "C:\Program Files\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 1"

AR Coding
Posts: 53
Joined: 02 May 2021 21:16

Re: Batch file help. Needing to position windows.

#18 Post by AR Coding » 23 Jan 2022 18:45

You can try tweaking Steffens code at post #14 (untested)

Code: Select all

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


%start% "C:\Program Files\Google\Chrome\Application\chrome.exe" 0 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);

buythedop
Posts: 3
Joined: 21 Jan 2022 11:41

Re: Batch file help. Needing to position windows.

#19 Post by buythedop » 24 Jan 2022 10:34

Sorry I don't have much technical knowledge. Is there no way I can use the window.exe program and then insert this function Window GPos x y as shown in message 8?

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

Re: Batch file help. Needing to position windows.

#20 Post by aGerman » 24 Jan 2022 11:10

buythedop wrote:
24 Jan 2022 10:34
Is there no way I can use the window.exe program and then insert this function Window GPos x y as shown in message 8?
The description of Window.exe states
Window.exe Get/set several values related to console screen window.
Since you want to target a browser window (not the console window) I'm afraid the answer is no.

Steffen

buythedop
Posts: 3
Joined: 21 Jan 2022 11:41

Re: Batch file help. Needing to position windows.

#21 Post by buythedop » 24 Jan 2022 15:35

Thanks for the reply!

Do you know of anyway I might be able to do this?

Post Reply