繁体   English   中英

如何使用 PowerShell 脚本编辑 VisualElementsManifest.xml?

[英]How to Edit a VisualElementsManifest.xml with a PowerShell Script?

我已经看过很多类似这篇关于如何使用 PowerShell 编辑 XML 文件的文章,但是,我无法获得任何适合我的解决方案(我对 PowerShell 和脚本编写只有一点经验)。

我想编辑位于C:\ProgramData\TileIconify\Windows Store中的Windows Store.VisualElementsManifest.xml Store.VisualElementsManifest.xml 以将其更改为:

<?xml version="1.0" encoding="utf-8"?>
<Application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" GeneratedByTileIconifier="true">
  <VisualElements ShowNameOnSquare150x150Logo="on" Square150x150Logo="VisualElements\MediumIconWindows Store.png" Square70x70Logo="VisualElements\SmallIconWindows Store.png" ForegroundText="dark" BackgroundColor="#41413D" TileIconifierColorSelection="Default" TileIconifierCreatedWithUpgrade="true" />
</Application>

对此:

<?xml version="1.0" encoding="utf-8"?>
<Application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" GeneratedByTileIconifier="true">
  <VisualElements ShowNameOnSquare150x150Logo="on" Square150x150Logo="VisualElements\MediumIconWindows Store Dark.png" Square70x70Logo="VisualElements\SmallIconWindows Store Dark.png" ForegroundText="dark" BackgroundColor="#41413D" TileIconifierColorSelection="Default" TileIconifierCreatedWithUpgrade="true" />
</Application>

我很困惑,因为 VisualManifest.xml 文件中的字符串充满了引号和空格,这会破坏 PowerShell 脚本,而且我读过的线程都没有解释如何处理它。

看来您正在寻找更新 XML 的 2 个属性Square150x150LogoSquare70x70Logo ,如果是这种情况,您可以试试这个:

$filePath = 'Path\to\Windows Store.VisualElementsManifest.xml'
$xml = [xml]::new()
$xml.Load($filePath)
$visualElements = $xml.Application.VisualElements
$visualElements.Square150x150Logo = "VisualElements\MediumIconWindows Store Dark.png"
$visualElements.Square70x70Logo   = "VisualElements\SmallIconWindows Store Dark.png"
$xml.Save($filePath)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM