Starting chrome with a new profile each time


I am trying to write a script that starts google-chrome each time with a new profile. So this would looks like:

./chrome --profile-directory=“TEMP”

then if the script is executed for a second time it should add a number to “TEMP”, like ./chrome --profile-directory=“TEMP1”

What would be the best way to do this? Any help is much appreciated!


Welcome to the forum. :wave:t4:

What have you tried so far?

How far would you like to go this way? Do you reset the numbers at a certain point?

You need to keep track of the numbers you used already. You could save the current used number in a file or in the registry. When the script starts you have to read this number and increase it for the run command for Chrome.

Hi Olaf,

Thank you!

I have just started learning powershell, but unfortuantly this is what I got, I don’t know how to get parameter working within the --profile-directory.

$chrome= 'chrome.exe ’
$parameter = ‘(0…1000) | get-Random - count 1’
& chrome --profile-directory=$parameter"

Please … when you post code, sample data, console output or error messages format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in <---- Click :point_up_2:t4: :wink:

You may (re-)read the help topic about

With single quotes you specify a string. That’s not what you need here. :wink: It should be

$parameter = 0..1000 | Get-Random -Count 1

If you want to have more than just a number as directory name you can combine a given string with the content of a variable:

& chrome --profile-directory="temp_$parameter"
1 Like

Just a heads-up here.
If you don’t save the used directory numbers somewhere and add a check for those in your script. There is a risk that Get-Random generates the same number twice or more which would then reuse the same directory and presumably defeat the purpose of the script.
How many unique profiles do you think you need at each runtime?
Would it be worth it to clear existing profiles before each run of the script?

1 Like

Hi Laage,

Thank you for the heads-up, you are right. I suppose there might be 10 to 15 instances this would be the case. I am still trying to figure out how to do this and when in the process the profiles should be removed? What if someone just starts a vanilla verison of chrome, will it show multiple profiles? This would be confusing. Also what functions in poweshell would achieve tihs ?

Currenlty I am looking also at the following function instead of executing from a preset path. Would you recommend using the option below, would that be better?

[System.Diagnostics.Process]::Start("chrome" .. ]

It may not be a PowerShell issue. What do you actually want to achieve? There might be a better solution. :wink:

1 Like

At the library where I am working/volunteering we are launching a new program. This program has a limitaiton in that once you are logged using chrome no second person is able to login using hiis/her own login credentials. Chrome saves the login information. An option would be to launch an incognito version, but tha would be very limited.

I am trying to achieve the following:

  • create a ps1 script that launches chrome with a new profile each time someone starts the program and clears existing profiles.
  • make sure that once a ‘vanilla’ version of chrome is started people won’t see a list of chrome profiles

That sounds like you work in a kind of kiosk mode environment and you have different users using the same OS logon, right?
Using Chrome with some personalized login data would leave personal data from each user in the system accessable to any subsequent user. That does not sound like a good idea for me, sorry. :man_shrugging:t4:

You can set up Chrome to NOT save logins and passwords and other stuff and I would recommend to use this instead of a potentially error prone approach messing with the Chrome profiles. :wink:

Hi Olaf,

Absolutely agree with you but unfortunately this new system is not setup in this way. We are using desktop computers to login into a webbased system. Once you are logged in it keeps you logged in and if you run the program again it automatically logs you in. If one disables settings such as not storing passwords and cookies for example, it becomes impossible to login :frowning: ( I already looked into this prior diving into this). This whole process has been exhausting and there is no budget to hire a real programmer. However, I am willing to pay out of my own pocket for some help.

Thank you so much for your help so far,


Hmmmm … ok … so if you don’t need old profiles anyway why don’t you simply reset Chrome each time before you start it? Instead of creating a new profile directory for each new instance you delete the profile folder and Chrome starts like it is freshly installed. :man_shrugging:t4: