How you can manage to view and edit all Advanced APPV package settings from commandline using Tweakappv

Backstory:

If you work with APPV you probably used the ability to connect several APPV packages with a Connection Group (CG).

We all know it’s time consuming when there is conflicting advanced COM and isolation settings between packages already produced since they all need the same settings to work in a CG.
First you have to open all packages, and then you have to see what’s different before you can make the same adjustment to all the needed packages, it takes time and it easy to forget something.

What we wanted to do:

So I have been working on an idea of developing a small  in-house PowerShell tool based on the fine work and ideas of Advanced Installers “tweakappv”with a colleague. 

Tweakappv works basically like a small APPV api, so if you can crack the commands and syntax you can basically edit everything in one or more packages without doing manual editing.

What we managed to do:

Using a lot of time on trial and error we did manage to change all advanced isolation settings in all tested packaged, even that of Appv Office  2013\365 without breaking it (We don’t change those in Office, but it’s fun to test complex packages just because you can).
Picture 1
In this first beta we first select the working folder with all our packages going into a CG, then the program will extract and open all packages Appv manifest xml files and list out the individual package settings they have in a table view in the GUI.
We can then select the same default settings we want to set on all the packages in that CG and compile them.

Picture 2
This second Log window just show the PowerShell output and if there is some errors in there.
It can take several minutes to compile a lot of big packages if you edit a lot of functions, since one settings has to be applied at the time then compiled on each package before the next will start, but you can put it to work while you fetch a cup of coffee.
Some settings have to be done using xsl transforms, here is the XSL for disabling Brower plugins:
<?xml version="1.0" encoding="utf-8"?>

<!--
  Update appv package manifest using the following command line:
  TweakAppv.exe /update "Your Application.appv" /transformmanifest AppxManifest.xml "DisableBrowserHelperObject.xsl"
-->
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                             xmlns:appx="http://schemas.microsoft.com/appx/2010/manifest"
                             xmlns:appv="http://schemas.microsoft.com/appv/2010/manifest"
                             xmlns:appv1.1="http://schemas.microsoft.com/appv/2013/manifest"
                             xmlns:appv1.2="http://schemas.microsoft.com/appv/2014/manifest">

  <xsl:output method="xml" version="1.0" omit-xml-declaration="no" encoding="UTF-8" standalone="yes" indent="yes"/>
 
   <!-- Copy nodes that are not BrowserPlugin -->
  <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
  </xsl:template>

  <!-- Comment BrowserPlugin -->
  <xsl:template match="/appx:Package/appv:Extensions/*[local-name()='Extension' and namespace-uri()='http://schemas.microsoft.com/appv/2013/manifest' and @Category='AppV.BrowserPlugin' and *[@Subcategory='BrowserHelperObject']]">
    <xsl:text disable-output-escaping="yes"> &lt;!-- </xsl:text>
      <xsl:copy>
        <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
    <xsl:text disable-output-escaping="yes"> --&gt; </xsl:text>
  </xsl:template>
 
</xsl:transform>
Here is the xsl to disable all objects from isolation:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://schemas.microsoft.com/appx/2010/manifest"
xmlns:appx="http://schemas.microsoft.com/appx/2010/manifest"
xmlns:appv="http://schemas.microsoft.com/appv/2010/manifest"
xmlns:appv1.1="http://schemas.microsoft.com/appv/2013/manifest"
xmlns:appv1.2="http://schemas.microsoft.com/appv/2014/manifest"
version="1.0"
exclude-result-prefixes="appx">

<xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

<xsl:template match='/appx:Package/appv:Extensions/appv:Extension[@Category="AppV.Objects"]' />

<xsl:template match="/appx:Package/appv:Extensions">
    <xsl:copy>
        <xsl:copy-of select="@*|node()"/>
               <appv:Extension Category="AppV.Objects">
                               <appv:Objects>
                              <appv:NotIsolate>
                                              <appv:Object Name="*" />
                              </appv:NotIsolate>
                               </appv:Objects>
               </appv:Extension>
    </xsl:copy>
</xsl:template>

</xsl:stylesheet>
Here is the xsl to delete all objects from isolation.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://schemas.microsoft.com/appx/2010/manifest"
xmlns:appx="http://schemas.microsoft.com/appx/2010/manifest"
xmlns:appv="http://schemas.microsoft.com/appv/2010/manifest"
xmlns:appv1.1="http://schemas.microsoft.com/appv/2013/manifest"
xmlns:appv1.2="http://schemas.microsoft.com/appv/2014/manifest"
version="1.0"
exclude-result-prefixes="appx">

<xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

<xsl:template match='/appx:Package/appv:Extensions/appv:Extension[@Category="AppV.Objects"]' />

</xsl:stylesheet>
Here is the xsl to change VFS settings:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://schemas.microsoft.com/appx/2010/manifest"
xmlns:appx="http://schemas.microsoft.com/appx/2010/manifest"
xmlns:appv="http://schemas.microsoft.com/appv/2010/manifest"
xmlns:appv1.1="http://schemas.microsoft.com/appv/2013/manifest"
xmlns:appv1.2="http://schemas.microsoft.com/appv/2014/manifest"
version="1.0"
exclude-result-prefixes="appx">

<xsl:param name="VFS" select="true"/>

<xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="appx:Package/appx:Properties/appv1.2:FullVFSWriteMode">
  <xsl:copy>
      <xsl:value-of select="$VFS"/>
    </xsl:copy>
  </xsl:template>

</xsl:transform>

Com settings can be set directly using tweakappv commands:
Here is the list of COM settings we use.
;twc


;Appv:ComIsolated 6
;appv:SoftwareClients 7
;appv:Objects 8
Del-Nodes "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration/appv:COM"
Del-Nodes "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration/appv:SoftwareClients"
Del-Nodes "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration/appv:Objects"

;end

;Appv:COMOFF 6,23,24,25
New-Element "AppxManifest.xml" -elementname "appv:ExtensionsConfiguration" -namespaceURI "http://schemas.microsoft.com/appv/2010/manifest" -createifnotexist
New-Element "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration" -elementname "appv:COM" -elementtext " " -namespaceURI "http://schemas.microsoft.com/appv/2010/manifest" -createifnotexist
Set-ElementAttribute "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration/appv:COM" -AttributeName "Mode" -AttributeValue "Off"
;end

;Appv:COMIntegrated 6,23,24,31,32,33-34,35-36
;New-Element "AppxManifest.xml" -elementname "appv:ExtensionsConfiguration" -namespaceURI "http://schemas.microsoft.com/appv/2010/manifest" -createifnotexist
;New-Element "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration" -elementname "appv:COM" -elementtext " " -namespaceURI "http://schemas.microsoft.com/appv/2010/manifest" -createifnotexist
New-Element "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration/appv:COM" -elementname "appv:IntegratedCOMAttributes" -elementtext " " -namespaceURI "http://schemas.microsoft.com/appv/2010/manifest" -createifnotexist
Set-ElementAttribute "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration/appv:COM" -AttributeName "Mode" -AttributeValue "Integrated"
Set-ElementAttribute "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration/appv:COM/appv:IntegratedCOMAttributes" -AttributeName "InProcessEnabled" -AttributeValue "true"
Set-ElementAttribute "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration/appv:COM/appv:IntegratedCOMAttributes" -AttributeName "InProcessEnabled" -AttributeValue "false"
Set-ElementAttribute "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration/appv:COM/appv:IntegratedCOMAttributes" -AttributeName "OutOfProcessEnabled" -AttributeValue "true"
Set-ElementAttribute "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration/appv:COM/appv:IntegratedCOMAttributes" -AttributeName "OutOfProcessEnabled" -AttributeValue "false"
;end

;appv:SoftwareClients 7,23,24,42,43,44-45
;New-Element "AppxManifest.xml" -elementname "appv:ExtensionsConfiguration" -namespaceURI "http://schemas.microsoft.com/appv/2010/manifest" -createifnotexist
;New-Element "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration" -elementname "appv:SoftwareClients" -elementtext " " -namespaceURI "http://schemas.microsoft.com/appv/2010/manifest" -createifnotexist
New-Element "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration/appv:SoftwareClients" -elementname "appv:ClientConfiguration" -elementtext " " -namespaceURI "http://schemas.microsoft.com/appv/2010/manifest" -createifnotexist
Set-ElementAttribute "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration/appv:SoftwareClients" -AttributeName "Enabled" -AttributeValue "false"
Set-ElementAttribute "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration/appv:SoftwareClients/appv:ClientConfiguration" -AttributeName "EmailEnabled" -AttributeValue "true"
Set-ElementAttribute "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration/appv:SoftwareClients/appv:ClientConfiguration" -AttributeName "EmailEnabled" -AttributeValue "false"
;end

;appv:Objects 8,23,50,51,52
;New-Element "AppxManifest.xml" -elementname "appv:ExtensionsConfiguration" -namespaceURI "http://schemas.microsoft.com/appv/2010/manifest" -createifnotexist
New-Element "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration" -elementname "appv:Objects" -elementtext " " -namespaceURI "http://schemas.microsoft.com/appv/2010/manifest" -createifnotexist
New-Element "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration" -elementname "appv:ApplicationCapabilities" -elementtext " " -namespaceURI "http://schemas.microsoft.com/appv/2010/manifest" -createifnotexist
Set-ElementAttribute "AppxManifest.xml" -xpath "appv:ExtensionsConfiguration/appv:Objects" -AttributeName "Enabled" -AttributeValue "false"
;end

Update 15.01.2020. Program now available for download on Github.


No comments:

Post a Comment