user4168715
user4168715

Reputation: 179

Change Chrome Settings via Powershell

I want to make a script to change the default page zoom in Chrome, however I do not know where these options are stored. I guess that I have to find an appropriate options text file, parse it, and then make a textual replacement there, using powershell in order to apply the changes. I need to do it every time I plugin my laptop to an external monitor, and it is kinda annowying to do it by hand

Any ideas?

Upvotes: 2

Views: 12624

Answers (2)

Phatmandrake
Phatmandrake

Reputation: 359

$Env:

Is a special PSdrive that contains many of the SpecialFolder Paths

$Env:LOCALAPPDATA

and

[Environment]::GetFolderPath( [Environment+SpecialFolder]::LocalApplicationData )

Yield the same result in addition to the rest of Mathias answer.

Upvotes: -1

Mathias R. Jessen
Mathias R. Jessen

Reputation: 174485

The default zoom level is stored in a huge JSON config file called Preferences, that can be found in the local appdata folder:

$LocalAppData = [Environment]::GetFolderPath( [Environment+SpecialFolder]::LocalApplicationData )
$ChromeDefaults = Join-Path $LocalAppData "Google\Chrome\User Data\default"
$ChromePrefFile = Join-Path $ChromeDefaults "Preferences"
$Settings = Get-Content $ChromePrefFile | ConvertFrom-Json

The default Page Zoom level is stored under the partition object, although it seems to store it as a unique identifier with some sort of ratio value, this is what it looks like with 100% zoom:

PS C:\> $Settings.partition.default_zoom_level | Format-List

2166136261 : 0.0

Other than that, I have no idea. I don't expect this to be a good idea, Chrome seems to update a number of binary values everytime the default files are updated, you might end up with a corrupt Preferences file

Upvotes: 7

Related Questions