Page 2 of 2

Re: Batch file help. Needing to position windows.

Posted: 13 Jan 2019 05:40
by aGerman
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

Re: Batch file help. Needing to position windows.

Posted: 21 Jan 2022 11:44
by buythedop
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"

Re: Batch file help. Needing to position windows.

Posted: 23 Jan 2022 18:45
by AR Coding
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);

Re: Batch file help. Needing to position windows.

Posted: 24 Jan 2022 10:34
by buythedop
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?

Re: Batch file help. Needing to position windows.

Posted: 24 Jan 2022 11:10
by aGerman
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

Re: Batch file help. Needing to position windows.

Posted: 24 Jan 2022 15:35
by buythedop
Thanks for the reply!

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