Multiple new browser windows from batch file

情到浓时终转凉″ 提交于 2021-02-09 06:56:15

问题


I have read through many threads here relating to my issue. My problem seems simple, but I cant find the final piece, or I'm just overlooking something obvious. I have found multiple answers, but none that I can get to work. I am simply trying to open 4 new Chrome windows, not tabs. I am almost there. What I am using will in fact open each one up and size and position it. But it is requiring me to close one down before the next one will start.

@echo off
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --new-window --window-position=1280,0 --window-size=640,512 "URL" 
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --new-window --window-position=1920,0 --window-size=640,512 "URL 2" 
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --new-window --window-position=1280,512 --window-size=640,512 "URL 3" 
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --new-window --window-position=1920,512 --window-size=640,512 "URL 4"
exit

I have also tried a second bat file, and it will open 4 windows and size them, and does not require me to kill the browser window before the next one will start, but it is ignoring the positioning, so they all just stack on top of each other.

@echo off
start chrome --new-window --window-position=1280,0 --window-size=640,512 "URL"
start chrome --new-window --window-position=1920,0 --window-size=640,512 "URL 2"
start chrome --new-window --window-position=1280,512 --window-size=640,512 "URL 3"
start chrome --new-window --window-position=1920,512 --window-size=640,512 "URL 4"
exit

What am I missing? I will use either method if someone can just help get me that last yard. Thanks.


回答1:


Thanks to user PA in the comments section. So this issue appears to be a quirk of Chrome. Its a bit tedious, especially if you want to do this with several windows. But I created 4 profiles in Chrome and then called them each in the batch. This resolved the issue.

@echo off
start chrome --user-data-dir="C:\Users\(username)\AppData\Local\Google\Chrome\User Data\Default"--new-window --window-position=1280,0 --window-size=640,512 "URL"
start chrome --user-data-dir="C:\Users\(username)\AppData\Local\Google\Chrome\User Data\user2" --new-window --window-position=1920,0 --window-size=640,512 "URL 2"
start chrome --user-data-dir="C:\Users\(username)\AppData\Local\Google\Chrome\User Data\user3"--new-window --window-position=1280,512 --window-size=640,512 "URL 3"
start chrome --user-data-dir="C:\Users\(username)\AppData\Local\Google\Chrome\User Data\user4"--new-window --window-position=1920,512 --window-size=640,512 "URL 4"
exit


来源:https://stackoverflow.com/questions/31592190/multiple-new-browser-windows-from-batch-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!