Change Chrome Settings via Powershell

前端 未结 2 665
北恋
北恋 2021-01-26 06:12

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

相关标签:
2条回答
  • 2021-01-26 06:48

    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

    0 讨论(0)
  • 2021-01-26 06:53
    $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.

    0 讨论(0)
提交回复
热议问题