Friday, December 23, 2016

Right Click and Publish App-V Package along with Dynamic Configuration File - Context Menu Shortcut


In my previous blog I had posted about a simple registry tweak to publish packages globally/User by just right clicking and selecting the option. But in that method, it will not use the dynamic configuration file. And so I have covered how to do that in this blog.


copy the below code in notepad and save it in .reg format. After saving, double click on it and register the keys.


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.appv]
@="appvex"

[HKEY_CLASSES_ROOT\appvex]

[HKEY_CLASSES_ROOT\appvex\shell]

[HKEY_CLASSES_ROOT\appvex\shell\Publish Globally]
@="&Publish Globally"

[HKEY_CLASSES_ROOT\appvex\shell\Publish Globally\command]
@="cmd /c start /b /wait powershell.exe -nologo -ExecutionPolicy bypass -file \"c:\\Publish globally.ps1\" \"%1\""

[HKEY_CLASSES_ROOT\appvex\shell\Publish to User]
@="Publish to &User"

[HKEY_CLASSES_ROOT\appvex\shell\Publish to User\command]
@="cmd /c start /b /wait powershell.exe -nologo -ExecutionPolicy bypass -file \"c:\\Publish to user.ps1\" \"%1\""


Publish Globally:


Copy the below code in a notepad and save it as Publish globally.ps1. Place this file in C:\ drive. If you are planning to keep it elsewhere, then edit the registry entry accordingly.


#Import App-V Client Module
Import-Module AppvClient

#Enable execution of scripts
Set-AppvClientConfiguration -EnablePackageScripts 1


#get appvfile

$appvfile = "$args"

Write-Host $appvfile

#get appv file location

$appvlocation = $appvfile.lastindexof("\")

$location = $appvfile.substring(0,$appvlocation)

Write-Host $location

Write-Host "Path is valid = $(Test-Path $location)"

Set-Location $location 

#get _Deploymentconfig file

ForEach ($file in "$location") 

{
$Name=Get-ChildItem $file
  for ($i = 0; $i -lt $Name.count; $i++)
  {
   
    if ($Name[$i].Extension -eq ".xml")
   {
    $xmlFileName = $Name[$i].FullName
    if ($xmlFileName.contains("_DeploymentConfig"))
    {
     $deploymentconfigfile = $xmlFileName
Write-Host "$deploymentconfigfile"

    }
    
    
   }

  }


Add-AppvClientPackage -path $appvfile -DynamicDeploymentConfiguration "$deploymentconfigfile" | Publish-AppvClientPackage -Global  | Mount-AppvClientPackage 

}


Publish to User:

Copy the below code in a notepad and save it as Publish to user.ps1. Place this file in C:\ drive. If you are planning to keep it elsewhere, then edit the registry entry accordingly.



#Import App-V Client Module
Import-Module AppvClient

#Enable execution of scripts
Set-AppvClientConfiguration -EnablePackageScripts 1


#get appvfile

$appvfile = "$args"

Write-Host $appvfile

#get appv file location

$appvlocation = $appvfile.lastindexof("\")

$location = $appvfile.substring(0,$appvlocation)

Write-Host $location

Write-Host "Path is valid = $(Test-Path $location)"

Set-Location $location 

#get _userconfig file

ForEach ($file in "$location") 

{
$Name=Get-ChildItem $file
  for ($i = 0; $i -lt $Name.count; $i++)
  {
   
    if ($Name[$i].Extension -eq ".xml")
   {
    $xmlFileName = $Name[$i].FullName
    if ($xmlFileName.contains("_UserConfig"))
    {
     $UserConfigfile = $xmlFileName
Write-Host "$UserConfigfile"

    }
    
    
   }

  }


Add-AppvClientPackage -path $appvfile | Publish-AppvClientPackage -DynamicUserConfigurationPath "$UserConfigfile"| Mount-AppvClientPackage 

}


Context Menu Preview:


When you right click any .appv file, it will show the below two context menu shortcuts.If you want to publish globally along with the deploymentconfig file then click on Publish Globally and to publish to a user along with the Userconfig file then click on Publish to User.


Right-Click and Publish AppV packages using ContextMenu Shortcut - A simple registry hack

I always wanted a simple trick to install the App-V virtual packages in a single click without any need to open powershell and type commands in a standalone machine. I have worked on many software's and  used to see some of them provide context menu shortcut (notepad++, winzip etc..) So I had an idea to create a simple registry tweak to publish the virtual packages either globally or to a user by just right clicking a .appv file using context menu option.

Copy the below code and save it in a notepad with .reg extension. Double click and register it.


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.appv]
@="appvex"

[HKEY_CLASSES_ROOT\appvex]

[HKEY_CLASSES_ROOT\appvex\shell]

[HKEY_CLASSES_ROOT\appvex\shell\Publish Globally]
@="&Publish Globally"

[HKEY_CLASSES_ROOT\appvex\shell\Publish Globally\command]
@="cmd /c start /b /wait powershell.exe  -nologo -ExecutionPolicy bypass -command \"& {add-appvclientpackage '%1' |publish-appvclientpackage -global|mount-appvclientpackage}\""

[HKEY_CLASSES_ROOT\appvex\shell\Publish to User]
@="Publish to &User"

[HKEY_CLASSES_ROOT\appvex\shell\Publish to User\command]
@="cmd /c start /b /wait powershell.exe  -nologo -ExecutionPolicy bypass -command \"& {add-appvclientpackage '%1' |publish-appvclientpackage |mount-appvclientpackage}\""


After registering the registry key, now you should be able to see the below highlighted context menu shortcut when you right-click any .appv file. To publish globally, click on the Publish Globally shortcut and vice versa.





Registry Peak:






Note: This doesn't add the dynamic configuration file while adding/publishing. I will post it separately in my next blog.


Disclaimer - Test it with caution as I don't hold any responsibility for any problem caused. This is issued for experimental purpose only.

Merry Christmas and a Happy New Year!!

If you would like to try on your own refer to the below link which can guide you.

Reference - http://www.howtogeek.com/107965/how-to-add-any-application-shortcut-to-windows-explorers-context-menu/


Friday, November 25, 2016

Advanced Installer 13.3 - fixes MSI launch condition issue in Windows 10 anniversary update 1607

Earlier when trying to install the Advanced Installer created virtual package through MSI format in windows 10 anniversary update 1607, it failed to install with the below error.




This issue is caused because of a launch condition in MSI which has been set to check for App-V client installed as a pre-requisite. Since App-V comes inbox with windows 10 v1607, the pre-req check fails with the above error.

This was a known issue even with App-V created packages and it was reported back to Microsoft.

Meantime I had a chance to talk with the Advanced Installer team about this issue. They quickly reported that they will look into this issue ASAP and come back with a fix. To my wonder they released an update within a short time period. You can have a look on their release note about this bug fix.

http://www.advancedinstaller.com/release-13.3.html

Now using Advanced Installer 13.3 when you create a virtual package and use the MSI to install in windows 10 1607, it installs fine without any issue. I tested with few apps sequenced by Advanced Installer 13.3 and found it to be 100% success.


So I looked into the MSI created after virtualizing and saw that it had the same launch condition but with a different approach. They have used the APPV_5X_CLIENT_INSTALLED property which has been set using AppSearch.




In this case they have used to locate the registry existence (HKLM\Software\Microsoft\AppV\Client).





Since windows 10 has inbuilt App-V, it  has a registry for AppV with version 5.2.0.0 by default.





Now when you install the new Advanced Installer 13.3 created virtual package MSI, the launch condition gets satisfied as there is a registry key with a valid  version and so it gets installed successfully.


For earlier versions, it still fails. For now you can fix it using the below solutions.


Solution - Virtual applications packaged into MSI format doesn’t install on inbox App-V client in Windows 10 Anniversary update 1607


UPDATED LINK -https://technet.microsoft.com/en-us/itpro/windows/manage/appv-release-notes-for-appv-for-windows

Monday, November 14, 2016

TweakAppv - Change PackageID, VersionID, Version to a predefined value

If you want to change the Package Version or VersionID, you can do it by exporting the AppxManifest.xml file from App-v 5.1 sequencer and do the changes. But after importing it back and saving the package, those values changes to some other random values. The version also gets incremented. So how to set them to a predefined value?


Advanced Installer has released a free tool called Tweakappv. It can be downloaded from the below link.It makes things so easy that you can also do a batch conversion for bulk packages.


http://www.advancedinstaller.com/appv-automation.html


Change Version:


Follow the below command to change the version value to a predefined value.





You can note that after publishing the version has been changed to the value 4.0.0.6 which we had set using Tweakappv.





Change VersionID:


Follow the below command to change the VersionID to a predefined value.





Change PackageID:


Follow the below command to change the PackageID to a predefined value.





NOTE - The value you provide for -attributename is case sensitive.

Thursday, October 27, 2016

Solution: How to launch two App-V 5.x sequenced different versions of firefox side by side

Recently I came across an issue in TechNet which was quite interesting.

Issue:

I was able to publish two Mozilla Firefox (41.0, 49.0) to a client machine. I've added Desktop Icons with the respective version on it to differentiate one from the other.
If I open them individually, not keeping both opened, I can confirm the version of the browser checking the Help otpion, however if I open one browser say 41.0, keep it opened, then open the second browser version 49.0 , the first browser version 41.0 will take precedensce on the second instance too.This can be checked by opening up help and checking the version. The second window showed 41.0 version even though it was 49.0 version firefox shortcut.

https://social.technet.microsoft.com/Forums/en-US/c364b975-a2e4-425f-8d4c-88fdc7550599/having-two-mozilla-firefox-versions-from-appv-published-to-a-computer-if-i-open-both-versions-one?forum=mdopappv&prof=required

Solution:

Edit the dynamic config file and add the below -no-remote in the <Arguments> tag. -no-remote will tell the FireFox to use a new instance of it while opening, if we don't pass the argument then it will open a new window but it will be the same instance of previously opened FireFox.

<Shortcuts Enabled="true">
        <Extensions>
          <Extension Category="AppV.Shortcut">
            <Shortcut>
              <File>[{Programs}]\Mozilla Firefox.lnk</File>
              <Target>[{ProgramFilesX86}]\Mozilla Firefox\firefox.exe</Target>
              <Icon>[{Windows}]\Installer\{xxxxxxxxx-0B398xxxxxxF}\Icon_firefox1.exe.0.ico</Icon>
              <Arguments> -no-remote  </Arguments>
              <WorkingDirectory>[{ProgramFilesX86}]\Mozilla Firefox\</WorkingDirectory>
              <ShowCommand>1</ShowCommand>
              <ApplicationId>[{ProgramFilesX86}]\Mozilla Firefox\firefox.exe</ApplicationId>
            </Shortcut>
          </Extension>
        </Extensions>
      </Shortcuts>


Save the deploymentconfig/user config file and add it while publishing.

Reference - http://kb.mozillazine.org/Opening_a_new_instance_of_Firefox_with_another_profile

Monday, October 24, 2016

Solution - Virtual applications packaged into MSI format doesn’t install on inbox App-V client in Windows 10 Anniversary update 1607

We see that the solution provided in the link from Microsoft for the msi (sequenced with App-V 5.1 or earlier) failure in windows 10 v1607 doesn't seem to fix the issue.


https://technet.microsoft.com/en-us/itpro/windows/manage/appv-release-notes-for-appv-for-windows

We see the below Msidb.exe not found error running the command as said in the link.





When checked for Msidb.exe, it was found in c:\program files(x86)\windows kits\10\bin. Changed the -msidbpath to c:\program files(x86)\windows kits\10\bin and tested. It fails too. Changed it to c:\program files(x86)\windows kits\10\bin\msidb.exe. It fails too.




The update-AppvMsiPackage.ps1 from C:\Program Files (x86)\Windows Kits\10\Microsoft Application Virtualization\Sequencer seems to look for the location c:\program files(x86)\windows kits\10\bin\msidb.exe which is not located after installing the windows 10 sdk. The actual path where the msidb.exe is located after installing windows 10 sdk is c:\program files(x86)\windows kits\10\bin\x86\msidb.exe



 


The above highlighted code needs to be changed to $msidbExe = Join-Path -Path $msSdkPath -ChildPath "Bin\x86\MsiDb.exe"

Save the modified code and run the command. Now the solution works fine and the MSI gets updated.


Thursday, August 11, 2016

App-V 5.1 sequencer and earlier doesn't work on windows 10 version 1607

When trying to install App-V 5.1 and earlier version of sequencer in windows 10 version 1607, it fails with the below error.




Solution: You would need to download the latest SDK for windows 10 version 1607 which has sequencer along with it. Using this sequencer you can proceed virtualizing apps.


https://developer.microsoft.com/en-us/windows/hardware/windows-assessment-deployment-kit

Tuesday, August 9, 2016

Exploring App-V & Ue-V in Windows 10 Anniversary update 1607

As all would have heard about the inbuilt App-V and Ue-V available with Windows 10 Anniversary update 1607 which has been released on August 2nd 2016.It is available only with the Windows Enterprise and Education editions. They will also be included in-box in Windows Server 2016 Standard and Datacenter. If you are using Windows 10 Professional or earlier and plan to upgrade to the Windows 10 Anniversary release, you will need to deploy the Enterprise edition to use App-V and UE-V on those devices.


I have already blogged about this in my previous post when I tested App-V and Ue-V in windows 10 build 14316 and some common issues found. You can have a look here in the below link.


http://app2pack.blogspot.com/2016/04/app-v-ue-v-available-by-default-in-new.html
http://app2pack.blogspot.com/2016/04/windows-10-build-14327-enabling-or.html

By default App-V and Ue-V are disabled in the OS. You need to enable it to use them. It can be done by enabling in services,GPO or using Powershell commands.


Open services.msc from run command and enable the App-V client service.





GPO-  go to Computer Configuration > Administrative Templates > System > App-V
Run Enables App-V Client and then select Enabled. Restart the machine.






To know list of available commands for App-V in powershell, follow the below step.







To enable App-V ,Open elevated powershell x86 or x64 and type Enable-Appv.This will enable the App-V client and show the output as successfully enabled.



To know the status of App-V, type in the below command.This will show the status of App-V client enabled or not and whether there is any reboot required.




To test bulk App-V 5.0 or App-V 5.1 packages use the below powershell command.


http://app2pack.blogspot.com/2015/08/powershell-to-automate-publishing-of.html
http://app2pack.blogspot.com/2015/08/powershell-to-automate-publishing-of_26.html


To disable App-V, type in Disable-AppV. This will require a reboot.


Also when checked for App-V version we can see that it is 5.2.



Tested by installing the .MSI file generated by the sequencer and it seems to fail which also earlier failed in build 14316.




For now removing the Launch condition from the MSI worked. To know more check here.Hope Microsoft will rectify this issue soon.


UPDATE (10/08/2016) - Microsoft has provided a official workaround for this issue. Check here for information.


https://technet.microsoft.com/en-us/itpro/windows/manage/appv-release-notes-for-appv-for-windows


UPDATE (19/10/2016) - When following the above solution provided by Microsoft, there was still an issue stating that the Msidb.exe could not be located.To resolve this issue kindly look into the below useful links.


http://app2pack.blogspot.com/2016/10/solution-virtual-applications-packaged.html


http://packageology.com/2016/08/fix-app-v-sequencer-generated-msi-packages/


https://garytown.com/appv-for-windows-10-1607-update-packages-enable-in-windows


Update (26/10/2016) - Microsoft has provided a new working solution


https://technet.microsoft.com/en-us/itpro/windows/manage/appv-release-notes-for-appv-for-windows


Ue-V:

To know list of available commands for Ue-V, follow the below step.






Open elevated powershell and type Enable-Uev.This will require a reboot.This can also be enabled via enabling in services.msc.






You can also use GPO to enable UEV.Goto Computer Configuration > Administrative Templates > Windows Components > MicrosoftUser Experience Virtualization.Run Enable UEV. Restart is needed.






To know the status of Ue-V, type in the below command.This will show the status of Ue-V enabled or not and whether any reboot required.




To disable Ue-V, type the below command.





Wednesday, May 18, 2016

Use WMI to list published virtual packages - App-V 5.0 & 5.1

Recently I read an article from David Falkus as how to use WMI to list App-V applications published to the machine.You can use this method if not able to access Powershell and also this method can help in basic troubleshooting. I experimented this and it seems to be very useful. Below are the steps as how to use WMI to list published applications and connection groups.


1. Open Run and type wbemtest.



2. Select Connect button.




3. Enter root\appv and click connect.




4. Click Enum Instances.




5. Enter AppvClientPackage and click ok. Also you can use AppvClientConnectionGroup to list the published Connection Groups.




6. This will list the packages that are published to the machine.




7. When you double click the package it will list the properties of the package like InUse, PackageID, VersionID etc.




8. This method is similar to that of using Get-AppvClientPackage in Powershell.


Friday, April 29, 2016

Windows 10 Build 14327 - Enabling or Disabling AppV/Uev shows success or failure status

Earlier in my previous blog I have mentioned that Enable-AppV, Disable-AppV, Enable-UeV, Disable-UeV commands in powershell doesn't show any success or failure result.

http://app2pack.blogspot.in/2016/04/app-v-ue-v-available-by-default-in-new.html

Recently Microsoft has released its windows 10 build 14327 insider preview release. So had a chance to test this case. when tested it shows the result that the App-V/Ue-V was successfully enabled/disabled. Finally there won't be any confusion whether the service is actually enabled or not.



NOTE: Reboot will be required when enabling/disabling.

Thursday, April 28, 2016

Project Centennial - First hands on Converting desktop apps to Universal Windows Platform (UWP)

There was a huge expectation about the Project Centennial also famously known as Project C. I promise it will not disappoint any of you. I was very eager to have my hands on it and experiment it more and so here I am explaining the conversion steps in detail with a test desktop app.

Prior to conversion one should know the advantages of converting desktop apps to UWP. To know more check the below link.

https://msdn.microsoft.com/windows/uwp/porting/desktop-to-uwp-root

Microsoft has released its pre-release version of Desktop App Converter tool which can be used to convert all the existing desktop apps written for .NET 4.6.1 or Win32 to the Universal Windows Platform (UWP).

Desktop App Converter tool converts a desktop Windows installer such as MSI or EXE to an AppX package that can be deployed to a Windows 10 desktop.

Requirements:

1. Windows 10 Build 10.0.14316.0 or higher(Should be installed physically. Converter will fail in a VM image)
2. Desktop App Converter ( Download - Here )
3. Windows Software Development Kit (SDK) for Windows 10 ( Download Here )

The Desktop App Converter will download two files. BaseImage-14316.wim and
DesktopAppConverter.zip.Extract the DesktopAppConverter.zip files to a desired location.


You can see that there are two files (DesktopAppConverter.cmd and DesktopAppConverter.ps1) DesktopAppConverter.cmd is a cmd wrapper for DesktopAppConverter.ps1.To know more type DesktopAppConverter.cmd -? You can use either CMD or Powershell file for converting purposes.


Now lets convert a test desktop app. Here I am going to use Notepad++ to convert into UWP.
 
Open Powershell as admin and set the execution policy to unrestricted or bypass.



Enter the below command in the Powershell.The setup command will make the Converter to expand the given base image(BaseImage-14316.wim). To know more about these parameters have a look at the below article.

https://msdn.microsoft.com/windows/uwp/porting/desktop-to-uwp-run-desktop-app-converter


"path to DesktopAppConverter.ps1" -Setup -BaseImage "path to BaseImage-14316.wim"

If it asks for reboot,Restart the machine and run the command again.

Also note that if you give the absolute path for the DesktopAppConverter.ps1 it will fail. You would need to give the relative path to make it work properly.





It will take some time to expand the base image, so you would need to wait patiently.
It expands the base image to the below path.



Enter the below command to perform conversion in an elevated Powershell.
"path to DesktopAppConverter.ps1" Installer "C:\test\npp.6.8.2.Installer.exe" -InstallerArguments "/S" -Destination "C:\Output\notepadplusplus"
-PackageName "Notepadplus" -Publisher "CN=Notepadplusplus" -Version 6.8.2.0 -ExpandedBaseImage C:\ProgramData\Microsoft\Windows\Images\BaseImage-14316 -Verbose -LogFile "c:\notepad.log"

Make sure you do not keep any other application in the folder. keep only the application that needs to be converted in the Installer location. In this case only notepad++ installer exe should be kept.








This command will run the notepad++ Installer silently in an isolated environment using a clean base image which we downloaded along with the converter(We have expanded the WIM image earlier). It will capture all the changes like registry and file system I/O made by the notepad++ installer and packages it as part of the output.

You can see the verbose log in the screen as we have used -verbose parameter. Also a log file will be generated in the C:\ drive as we have explicitly mentioned in the above command using -LogFile parameter.


So what happens exactly when running the above script. will see more (Refer the above screenshots while reading the below steps for easy understanding).
  1. The script does a Pre-Requisite check like checking Minimum Windows Version,PowerShell Version etc..
  2. It Validates the given parameters like Installer presence, Output Folder presence (If it is not there it will create the folder)
  3. It will Setup Conversion Environment for Capturing.
  4. It Creates AppX Manifest file. This acts as the Core DNA of the Application. It is the Metadata for the package that contains all the required information including extension points, FTA's, shortcuts and the identity names associated with the package.You can customize this file for any changes to be made after capturing the package.
  5. It Generates Virtual File System (VFS). All the files that are captured will be placed here.Additionally there will be Assets Folder which contains Icons [This is created by the Converter].If you are working on App-V then you can relate these things as both are quite same.
  6. It Generates Virtual Registry System (Registry.dat). It Contains all the registry changes that were made by the Installer.
Output – Below is the image of the output that we get,




Assets folder contains the icons for the package. By default it shows X symbol (I guess this will be rectified in the original release). You would need to change these to original icons. Just extract the icons and replace them here with the same name, so that there will be no changes required to modify the AppXmanifest file further.




If we want to create .AppX Package then we need to follow the below steps.

Use MakeAppX.exe to convert to Appx format (It will be available as a part of Windows SDK)


MakeAppx.exe Pack -d "Path of Directory Containing the VFS, Registry.Dat & AppXManifest.xml"-p "Path to output folder"



This will build the loose files to a single AppX package .



In-order to deploy and test the .appx package using the Add-AppxPackage cmdlet, it requires that the application package (.appx) must be signed. For this we can use SignTool.exe, which comes with the Microsoft Windows 10 SDK.





Once signed (you can use a dummy certificate for this step), you can install it successfully.

Testing :Open elevated powershell and run the below command.


Add-AppxPackage "Path to .AppX File"

This will install the package successfully.


NOTE:

At present the Desktop App Converter supports the conversion process only on a 64-bit OS. You can deploy the converted .appx packages to a 64-bit OS only. Desktop App Converter requires the desktop installer to run under unattended mode.

MVP Tim Mangan has mentioned in his blog that there is a bug in the converter.If you give it a MSI based installer, it ignores the command line parameters that you provide and injects it’s own.To know more check his official blog page.(Interesting read :) )
http://www.tmurgent.com/TmBlog/?p=2448
Also check the review from MVP Rory Monaghan about Project C in his blog below.
http://rorymon.com/blog/?p=3490
Also check the blog post from Simon Binder below.
https://bindertech.wordpress.com/2016/04/08/get-started-with-project-centennial/

You can also watch the below video from Microsoft Channel9  to know more about the use of Desktop App Converter tool to convert desktop apps to UWP with demo.


To know more check the below official link from Microsoft.

https://developer.microsoft.com/en-us/windows/bridges/desktop