Windows libraries の仕様
モチベ
どうなってるのか確認したい。そして PowerShell で操作したい。
対象
%AppData%\Microsoft\Windows\Libraries\*.library-ms
概要
実態としては、ただの XML ファイルの様だ。
仕様
xpath: /libraryDescription/searchConnectorDescriptionList/searchConnectorDescription
検索
xpath: /libraryDescription/searchConnectorDescriptionList/searchConnectorDescription[*]/simpleLocation
具体例
<?xml version="1.0" encoding="UTF-8"?>
<libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library">
<name>@shell32.dll,-34575</name>
<ownerSID>S-1-5-21-379071477-2495173225-776587366-1000</ownerSID>
<version>1</version>
<isLibraryPinned>true</isLibraryPinned>
<iconReference>imageres.dll,-1002</iconReference>
<templateInfo>
<folderType>{7d49d726-3c21-4f05-99aa-fdc2c9474656}</folderType>
</templateInfo>
<searchConnectorDescriptionList>
<searchConnectorDescription publisher="Microsoft" product="Windows">
<description>@shell32.dll,-34577</description>
<isDefaultSaveLocation>true</isDefaultSaveLocation>
<simpleLocation>
<url>knownfolder:{FDD39AD0-238F-46AF-ADB4-6C85480369C7}</url>
<serialized>MBAAAEAFCAAA...MFNVAAAAAA</serialized>
</simpleLocation>
</searchConnectorDescription>
<searchConnectorDescription publisher="Microsoft" product="Windows">
<description>@shell32.dll,-34579</description>
<isDefaultNonOwnerSaveLocation>true</isDefaultNonOwnerSaveLocation>
<simpleLocation>
<url>knownfolder:{ED4824AF-DCE4-45A8-81E2-FC7965083634}</url>
<serialized>MBAAAEAFCAAA...HJIfK9AAAAAA</serialized>
</simpleLocation>
</searchConnectorDescription>
</searchConnectorDescriptionList>
</libraryDescription>
serialized
をムリヤリ読んでも、バイナリだから意味不明だった。
xpath: /libraryDescription/searchConnectorDescriptionList/searchConnectorDescription[*]/simpleLocation/serialized
serialized: This element contains the base64-encoded ShellLink pointing to the location defined in the <url> element. Windows 7 creates the ShellLink from the value of the <url> element and properly updates this field on the first load of this library, so it should be left empty by the author.
ShellLink
COM
スルー
あつかうのはムリそうだ
PowerShell で XML
問題
なにも返ってこないぞ…
解決
Even a "default" namespace has to be specified
-Namespace
$ns = @{lib = 'http://schemas.microsoft.com/windows/2009/library'}
Select-Xml -Namespace $ns -XPath '//lib:libraryDescription'
XML Node
完成
$ns = @{lib = 'http://schemas.microsoft.com/windows/2009/library'};
ls .\Books.library-ms |
Select-Xml -Namespace $ns -XPath '//lib:url' |
ls -LiteralPath { $_.Node.InnerText } -File -Recurse |
where -not IsReadOnly |
Set-ItemProperty -Name IsReadOnly -Value $true
ref.