0

I am trying to open a url in chrome in incognito mode in multiple profiles using bat file. The code should be such that, it opens the URL in a particular profile, in incognito mode, wait for 45 seconds and then closes the profile. Following this, it should open another profile and do the same, until all the profile mentioned in the code is opened and closed.

I have attached my sample code which I tried, but it actually kills all the processes associated with the chrome and subsequent closing and opening doesn't happens.

Following is my code :

@echo off

rem Define the profiles that you want to open.
set profile1="Profile 1"
set profile2="Profile 2"
set profile3="Profile 3"

rem Define the URL that you want to open.
set url="https://www.google.com"

rem Open Chrome in incognito mode for each profile.
for /f "delims=" %%p in ('chrome --profile-list') do (
    rem The profile name is the first item in the list.
    rem The profile path is the second item in the list.
    set profile_name=%%p
    set profile_path=%%q

    rem Open Chrome in incognito mode for the profile.
    echo Opening Chrome in incognito mode for profile "%profile_name%"
    start chrome --incognito --new-tab --force-new-tab "%profile_path%" "%url%"

    rem Sleep for one second.
    timeout /t 1

    rem Close Chrome.
    taskkill /F /IM chrome.exe
)

1 Answers1

0

when i execte the command chrome --profile-list in cmd, didn't return profiles list for me. just opened a new instance of chrome. I tried to search about it. Nothing found. Example list of chrome switchs

It seems there is a problem there, because below code is opening chrome in incognito mode 3 times correctly:

@echo off

set profile_path="C:\Users\r.ahmadi\AppData\Local\Google\Chrome\User Data\NewUser"

set url="https://www.google.com"

for /L %%a in (1,1,3) do (  
    start chrome --incognito --new-tab --force-new-tab "%profile_path%" "%url%"
    timeout /t 3
    taskkill /F /IM chrome.exe
)

of course you have to create a NewUser to test this code. Create a new user