- MS Windows 10 Pro v10.0.18362 Build 18362 (64-bit)
- Google Chrome Browser v79.0.3945.88 (Official Build) (64-bit)
- AutoHotkey v1.1.30.01
This is an article to create a standalone application which lists all the Google Chrome Profiles on your Windows 10 workstation in alphabetical order.
Why?
This program will be redundant if Google ever update their Chrome browser to list the multiple profiles in alphabetical order like it used to be... but to date they have not. So I made a program that lists the profiles in alphabetical order and can be double-clicked to open the Chrome browser with that profile.
How?
So you will need to be able to run AutoHotkey or create executables from an AHK file. Here is the code that creates a GUI with a ListView with rows that can be double-clicked to open the profile. As an overview:
- Setup a standard AutoHotkey GUI
- Loop through Google Chrome Profile folders named "Profile 1", "Profile 2", etc.
- Scan the preferences file for JSON key "name" and extract value.
- Hide the first column in the list view (contains "Profile 1", "Profile 2", ...)
- Sort the second column (contains "Joes Personal Profile", "Joes Work Profile", etc)
- Create subroutine for when listview row is double-clicked to open Chrome Browser with selected Profile.
#NoEnv #Warn SendMode Input SetWorkingDir %A_ScriptDir% #SingleInstance force ; -------------------------------------------------------------------------------------- ; Set program Defaults ; -------------------------------------------------------------------------------------- Title := "Joes Chrome Profile Opener" Desc := "This program will list all the Google Chrome profiles available from your login." Version := "1.0" Width := 400 Height := 800 BgColor := "FFFFFF" MarginX := 2 MarginY := 2 Options := "+Caption +Border +OwnDialogs" TempDir := "C:\Windows\Temp" ; -------------------------------------------------------------------------------------- ; Create GUI Gui, New, %Options%, %Title% v%Version% Gui, Font, s12, Verdana Gui, Color, %BgColor% Gui, Margin, %MarginX%, %MarginY% Gui, Add, ListView, w396 h775 gOpenProfile -Hdr +Grid, Profile|Client ProfilePath := "C:\Users\" A_UserName "\AppData\Local\Google\Chrome\User Data\Profile*" Loop, Files, %ProfilePath%, D { FullPathArray := StrSplit(A_LoopFileLongPath, "\") ThisFolder := FullPathArray[9] PreferenceFile := A_LoopFileLongPath "\Preferences" ; Get the preferences file from the profile FileRead, OutputContent, %PreferenceFile% NameStart := InStr(OutputContent, """name"":""")+8 NameEnd := InStr(OutputContent, """", false, NameStart+1) NameLength := NameEnd - NameStart ClientName := SubStr(OutputContent, NameStart, NameLength) LV_Add("", ThisFolder, ClientName, A_LoopFileLongPath) } LV_Modifycol() LV_Modifycol(1, 0) ; hide the first column LV_ModifyCol(2, "Sort") ; sort the second column (profile names) Gui, Font, s8, Verdana Gui, Add, StatusBar,, Ready. Gui, Show, w%Width% h%Height% x10 y10 Return ; -------------------------------------------------------------------------------------- ; Subroutine: OpenProfile OpenProfile: if (A_GuiEvent = "DoubleClick") { LV_GetText(ThisFolder, A_EventInfo, 1) ThisPathToOpen := """C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"" --profile-directory=""" ThisFolder """" Run, %ThisPathToOpen% } Return ; -------------------------------------------------------------------------------------- ; Closing subroutine GuiClose: CloseMe: ExitApp
- #NoEnv
- #Warn
- SendMode Input
- SetWorkingDir %A_ScriptDir%
- #SingleInstance force
- ; --------------------------------------------------------------------------------------
- ; Set program Defaults
- ; --------------------------------------------------------------------------------------
- Title := "Joes Chrome Profile Opener"
- Desc := "This program will list all the Google Chrome profiles available from your login."
- Version := "1.0"
- Width := 400
- Height := 800
- BgColor := "FFFFFF"
- MarginX := 2
- MarginY := 2
- Options := "+Caption +Border +OwnDialogs"
- TempDir := "C:\Windows\Temp"
- ; --------------------------------------------------------------------------------------
- ; Create GUI
- Gui, New, %Options%, %Title% v%Version%
- Gui, Font, s12, Verdana
- Gui, Color, %BgColor%
- Gui, Margin, %MarginX%, %MarginY%
- Gui, Add, ListView, w396 h775 gOpenProfile -Hdr +Grid, Profile|Client
- ProfilePath := "C:\Users\" A_UserName "\AppData\Local\Google\Chrome\User Data\Profile*"
- Loop, Files, %ProfilePath%, D
- {
- FullPathArray := StrSplit(A_LoopFileLongPath, "\")
- ThisFolder := FullPathArray[9]
- PreferenceFile := A_LoopFileLongPath "\Preferences" ; Get the preferences file from the profile
- FileRead, OutputContent, %PreferenceFile%
- NameStart := InStr(OutputContent, """name"":""")+8
- NameEnd := InStr(OutputContent, """", false, NameStart+1)
- NameLength := NameEnd - NameStart
- ClientName := SubStr(OutputContent, NameStart, NameLength)
- LV_Add("", ThisFolder, ClientName, A_LoopFileLongPath)
- }
- LV_Modifycol()
- LV_Modifycol(1, 0) ; hide the first column
- LV_ModifyCol(2, "Sort") ; sort the second column (profile names)
- Gui, Font, s8, Verdana
- Gui, Add, StatusBar,, Ready.
- Gui, Show, w%Width% h%Height% x10 y10
- Return
- ; --------------------------------------------------------------------------------------
- ; Subroutine: OpenProfile
- OpenProfile:
- if (A_GuiEvent = "DoubleClick")
- {
- LV_GetText(ThisFolder, A_EventInfo, 1)
- ThisPathToOpen := """C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"" --profile-directory=""" ThisFolder """"
- Run, %ThisPathToOpen%
- }
- Return
- ; --------------------------------------------------------------------------------------
- ; Closing subroutine
- GuiClose:
- CloseMe:
- ExitApp