App-V 5.x CLI Editor

Use the TweakAppV.exe command line App-V 5.x editor tool as a scripting alternative to the App-V 5.x GUI Editor. It is located in Advanced Installer's installation folder under bin/x86 subfolder.

Usage

  • TweakAppV.exe /Update <appv_package_path> *<commands> - updates an App-V package according to the specifed commands. *Commands can be chained on the same line one after the other and they will be applied accordingly if their syntax is correct. See all supported commands and their syntax in the section below.
  • TweakAppV.exe /BatchFileUpdate <appv_package_path> <batch_file_path> [-nofail] - updates an App-V package according to the commands sequence from the batch file. The -nofail switch will not stop subsequent commands if one command from the batch file fails. The first characters in the file must be ;twc;, please see the example below for details.
  • TweakAppV.exe /help [<command_name>] - shows the syntax for the specified command. If the <command_name> switch is omitted, the syntax for all supported commands will be listed.

Supported Commands

Files

  • /Add-File <file_path_in_appv_package> <file_source_path> - adds a file from the disk in the specified location from the App-V package. This command also updates FilesystemMetadata.xml and Content_Types.xml manifest files.
  • /Update-File <file_path_in_appv_package> <file_source_path> - updates a file from the App-V package with the specified file from the disk.
  • /Del-File <file_path_in_appv_package> - deletes a file from the specified location in the App-V package. This command also updates FilesystemMetadata.xml and Content_Types.xml manifest files.
  • /Add-ScriptFile <file_source_path> - adds a script file from the disk in the App-V package.
  • /Update-ScriptFile <script_file_name> <file_source_path> - updates a script file from the App-V package with the specified script file from the disk.
  • /Del-ScriptFile <script_file_name> - deletes a script file from the App-V package.

Registry

  • /Set-RegistryKey <registry_key_path> [-virtualizationlevel <merge | overwrite | deleted>] - adds a new registry key to the specified registry location in the App-V package. The optional switch -virtualizationlevel can determine how the virtual application sees the registry key and it can be set for an existing registry key.

TipYou can use the above command for example when you want to virtualize an existing key (with all its children) from the target machine as deleted.

  • /Del-RegistryKey <registry_key_path> - deletes a registry key from the specified registry location in the App-V package.
  • /Set-RegistryValue <registry_key_path> [-valuename <registry_value_name>] [-type <sz | expandsz | dword | multisz | binary>] [-value <registry_value>] [-pathvariable] - creates or updates a registry value in the App-V package.

TipIf you need to create a multiple line registry value (REG_MULTI_SZ) use the %0A%0D separator in the value field (e.g. -value "first line%0A%0Dsecond line")

  • /Del-RegistryValue <registry_key_path> <registry_value_name> - removes a registry value from the App-V package.
  • /Set-VirtualizeRegValueDeleted <registry_key_path> <registry_value_name> - virtualize the specified registry value as deleted.

Note<registry_key_path> must point to an absolute path in the App-V registry hive.

Manifest

  • /Set-NodeText <AppxManifest.xml | FilesystemMetadata.xml | PackageHistory.xml | StreamMap.xml | [Content_Types].xml> -xpath <xml_xpath_expression> [-nodetext <xml_node_text>] - updates an existing node from the specified XML file.
  • /New-Element <AppxManifest.xml | FilesystemMetadata.xml | PackageHistory.xml | StreamMap.xml | [Content_Types].xml> [-xpath <xml_xpath_expression>] -elementname <xml_element_name> -namespaceURI <xml_namespaceuri> [-elementtext <xml_node_text>] [-createifnotexist] - creates or updates an XML element in the specified XML file.
  • /Set-ElementAttribute <AppxManifest.xml | FilesystemMetadata.xml | PackageHistory.xml | StreamMap.xml | [Content_Types].xml> [-xpath <xml_xpath_expression>] -attributename <xml_attribute_name> [-attributevalue <xml_attribute_value>] - creates or updates an attribute for an existing XML element.
  • /Del-SingleNode <AppxManifest.xml | FilesystemMetadata.xml | PackageHistory.xml | StreamMap.xml | [Content_Types].xml> -xpath <xml_xpath_expression> - removes a single node from the specified manifest file.
  • /Del-Nodes <AppxManifest.xml | FilesystemMetadata.xml | PackageHistory.xml | StreamMap.xml | [Content_Types].xml> -xpath <xml_xpath_expression> - removes multiple nodes from the specified manifest file.
  • /TransformManifest <AppxManifest.xml | FilesystemMetadata.xml | PackageHistory.xml | StreamMap.xml | [Content_Types].xml> <xsl_transform_file_path> [*<-param_name param_value>] - applies an XSL transform to the specified manifest XML file. *You can specify several <-param_name param_value> pairs.
  • /Update-PackageIdentity -packageid <identity_package_id> -versionid <identity_version_id> -version <identity_version> - updates package identity details. Instead of values you can also type in auto. This will generate new IDs or increment the version with 1.
  • /Update-PackageHistory -packagingengine <packaging_engine_name> -sequencerversion <sequencer_version> - updates the package history log. The default values are TweakAppV and its version. You can specify for example Sequencer and its version.

Examples

The following command sets the registry value from the specified location as deleted. This means the application won't see this value from the target machine.

TweakAppV.exe /Update "C:\Work\App-V packages\Sample.appv" /Set-VirtualizeRegValueDeleted "Registry\Machine\Software\Caphyon\Advanced Installer" "Sample Value"

The following command searches for the element "Types" in the root of "[Content_Types].xml", then creates a new "Default Extension" child element with a value of "pdf".

TweakAppV.exe /Update "C:\Work\App-V packages\Sample.appv" /New-Element "[Content_Types].xml" -xpath "/Types" -elementname "Default Extension" -namespaceURI "http://schemas.openxmlformats.org/package/2006/content-types" -elementtext "pdf" -createifnotexist

This is an example of a batch commands file:

;twc;

Del-SingleNode FilesystemMetadata.xml -xpath "appv:StaticDependencies"
New-Element FilesystemMetadata.xml -elementname "StaticDependencies" -namespaceURI "http://schemas.microsoft.com/appv/2010/FilesystemMetadata" -createifnotexist
New-Element FilesystemMetadata.xml -xpath "appv:StaticDependencies" -elementname "Executable" -namespaceURI "http://schemas.microsoft.com/appv/2010/FilesystemMetadata"
Set-ElementAttribute FilesystemMetadata.xml -xpath "appv:StaticDependencies/appv:Executable[last()]" -attributename "Long" -attributevalue "Root\VFS\ProgramFilesX86\CodeMeter\Runtime\bin\CodeMeterCC.exe"
New-Element FilesystemMetadata.xml -xpath "appv:StaticDependencies/appv:Executable[last()]" -elementname "Entry" -namespaceURI "http://schemas.microsoft.com/appv/2010/FilesystemMetadata"
Set-ElementAttribute FilesystemMetadata.xml -xpath "appv:StaticDependencies/appv:Executable[last()]/appv:Entry[last()]" -attributename "Long" -attributevalue "Root\VFS\SystemX86\WibuCm32.dll"