The Issues of Sequencing .bat Shortcuts in App-V 5.0

It not unusual that in the mix of all your weird and wonderful applications you will have a handful that will leverage a .bat file shortcut to kick off your application. Let’s deep dive into the mechanics of sequencing and delivering these type of applications.

Take this example where I have sequenced an application and a .bat file which I then have a shortcut to in the start menu as shown here:

The interesting part is when we deliver this application to the client we see the shortcut string transformed from what we see above to this:

%ALLUSERSPROFILE%\Microsoft\AppV\Client\Integration\5B9A87F2-AE71-46B1-9C21-33AC3EF63EE0\Root\mybatch.bat /appvve:5B9A87F2-AE71-46B1-9C21-33AC3EF63EE0_8DC3E0FE-5BE2-40B0-9ACE-248ADB34FA9A

The key part is in bold, the App-V client tries to make sure this .bat loads into the virtual environment by adding a switch against it specifying the package GUID and version GUID parameters. In this case, this doesn’t work as the parameter doesn’t like being passed against the .bat FTA.

Hence our application actually fails to see the virtualised location, not only that the virtual environment doesn’t even load and the application doesn’t show as in use in the client GUI.

In a real world scenario this could be a Java based application for example that is launched via a .bat, as the .bat doesn’t spin up the virtual environment, it will fail to find its Java components and error.

The Workaround

To get around this issue we need to make sure we explicitly call the actual application rather than the FTA, in this case cmd.exe.

We use a /c on the cmd.exe so that it executes the entire command specified and then stops. When we deliver this application to our client our shortcut looks like this:

C:\Windows\System32\cmd.exe /c %ALLUSERSPROFILE%\Microsoft\AppV\Client\Integration\5B9A87F2-AE71-46B1-9C21-33AC3EF63EE0\Root\mybatch.bat /appvve:5B9A87F2-AE71-46B1-9C21-33AC3EF63EE0_8DC3E0FE-5BE2-40B0-9ACE-248ADB34FA9A

Now what will happen on launch is we will call the local cmd.exe process and pass it the parameter of our .bat while loading it into the virtual environment specified by the /appvve switch.

This means the .bat has access to the virtual environment, shows as in use on the client GUI and can run successfully.

So to summarise, if you have similar apps in your environment and they fail because they cannot see the virtual environment, specify the parent .exe explicitly and let the App-V client handle the load of the virtual environment.

Thamim Karim