locked
App-V 5 DeploymentConfig.xml UserScripts. Is it possible to have more than one entry? RRS feed

  • Question

  • Hi,

    I have an application where the users need to be able to run a different pre-launch script depending upon the configuration they need.

    In App-V 4.6, I simply created a set of .osd's with different names for the users, that ran the different pre-launch scripts albeit pointing to the same .exe. 

    In App-V 5, I have run into a couple of headaches:

    Firstly, during sequencing, I created multiple shortcuts pointing to the same .exe. In App-V 5, these shortcuts get captured as a single application with multiple shortcut locations. As UserScripts in the DeploymentConfig.xml are run on a per-application basis and not per-shortcut, this means that there is no way to identify which shortcut has been run - and therefore no way to run a specific script per-shortcut. To counter this, I have created multiple copies of the .exe (yes, this is primitive but I couldn't think of an alternative!) and given each one a unique name, each shortcut now pointing to a differently named .exe. This effectively gives me the ability to identify which shortcut has been run and have the relevant pre-launch script execute.

    How should I really be doing this? Creating multiple copies of an .exe can't be the solution!

    Secondly, now that I have the ability to identify which pre-launch script I need to run in the DeploymentConfig.xml, how can I have more than one UserScript in the xml file?

    For example, importing the package with this code in PowerShell works fine (the package imports and on my.exe launch, Notepad pre-launches):

        <UserScripts>
          <StartProcess RunInVirtualEnvironment="true">
            <Path>C:\Windows\System32\notepad.exe</Path>
            <Arguments></Arguments>
            <Wait RollbackOnError="true"/>
            <ApplicationId>[{AppVPackageRoot}]\my.exe</ApplicationId>
          </StartProcess>
        </UserScripts>

    However, I want to have multiple UserScripts, pre-launching different apps for different ApplicationId's. For example, I want to have Notepad run if my.exe is called (as above) and Calc to run if my2.exe is executed:

        <UserScripts>
          <StartProcess RunInVirtualEnvironment="true">
            <Path>C:\Windows\System32\calc.exe</Path>
            <Arguments></Arguments>
            <Wait RollbackOnError="true"/>
            <ApplicationId>[{AppVPackageRoot}]\my2.exe</ApplicationId>
          </StartProcess>
        </UserScripts>

    My question - how can the scripts be combined into the same DeploymentConfig.xml?

    I have tried to combine the scripts but always receive an invalid .xml file error on package import. These are the combinations I have tried:

        <UserScripts>
          <StartProcess RunInVirtualEnvironment="true">
            <Path>C:\Windows\System32\notepad.exe</Path>
            <Arguments></Arguments>
            <Wait RollbackOnError="true"/>
            <ApplicationId>[{AppVPackageRoot}]\my.exe</ApplicationId>
            <Path>C:\Windows\System32\calc.exe</Path>
            <Arguments></Arguments>
            <Wait RollbackOnError="true"/>
            <ApplicationId>[{AppVPackageRoot}]\my2.exe</ApplicationId>
          </StartProcess>
        </UserScripts>

    and:

        <UserScripts>
          <StartProcess RunInVirtualEnvironment="true">
            <Path>C:\Windows\System32\notepad.exe</Path>
            <Arguments></Arguments>
            <Wait RollbackOnError="true"/>
            <ApplicationId>[{AppVPackageRoot}]\my.exe</ApplicationId>
          </StartProcess>
          <StartProcess RunInVirtualEnvironment="true">
            <Path>C:\Windows\System32\calc.exe</Path>
            <Arguments></Arguments>
            <Wait RollbackOnError="true"/>
            <ApplicationId>[{AppVPackageRoot}]\my2.exe</ApplicationId>
          </StartProcess>
        </UserScripts>

    and finally:

        <UserScripts>
          <StartProcess RunInVirtualEnvironment="true">
            <Path>C:\Windows\System32\notepad.exe</Path>
            <Arguments></Arguments>
            <Wait RollbackOnError="true"/>
            <ApplicationId>[{AppVPackageRoot}]\my.exe</ApplicationId>
          </StartProcess>
        </UserScripts>
    <UserScripts>
          <StartProcess RunInVirtualEnvironment="true">
            <Path>C:\Windows\System32\calc.exe</Path>
            <Arguments></Arguments>
            <Wait RollbackOnError="true"/>
            <ApplicationId>[{AppVPackageRoot}]\my2.exe</ApplicationId>
          </StartProcess>
        </UserScripts>

    Thanks for your help,

    Stu

    Tuesday, November 20, 2012 10:06 AM

Answers

  • Hi,

    We opened a case with MS asking how to use the equivalent of the AppV 4.6 pre-launch scripts (osd scripts), in AppV 5.0.

    The result of the case is that the use of these scripts has effectively been dropped in App-V 5.0:

    "...this behavior is by design.
     
    App-V 5.0 is designed to behave more in line with native application installations.
    The side benefit we had in versions before 5.0 is lost because of this. "

    Unbeliveably we are going to have to do something like modify our shortcuts to point to batch files to carry out pre-launch commands and then call the .exe.

    Is this progress?

    • Marked as answer by StuHed Monday, December 17, 2012 4:02 PM
    Monday, December 17, 2012 4:02 PM

All replies

  • Put the scripts into a UserConfig.xml instead. Create seperate config files for each group and publish the files to each user groups. About App-V 5.0 Dynamic Configuration


    Please remember to click "Mark as Answer" or "Vote as Helpful" on the post that answers your question (or click "Unmark as Answer" if a marked post does not actually answer your question). This can be beneficial to other community members reading the thread.


    This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

    Twitter: @stealthpuppy | Blog: stealthpuppy.com | The Definitive Guide to Delivering Microsoft Office with App-V


    Tuesday, November 20, 2012 10:29 AM
    Moderator
  • Hi Aaron,

    Thanks for your quick reply.

    Are you suggesting that all the scripts can be contained in a single UserConfig.xml or that a UserConfig.xml should be created per script?

    In this instance, all the users are in the same group - they all need the ability to change the config of the app depending on the backend they need to connect to at that time. The pre-launch scripts carry out the config changes. I could create a group per config and put all users in all the groups. However how would this work in practice? I'd be deploying multiple application configurations to the same users.

    Apologies if I am missing something obvious here.

    Stu

    Tuesday, November 20, 2012 10:49 AM
  • So from a user perspective, they might start each configuration by starting separate shortcuts (e.g. one for Prod and another for Test). Is that what you're trying to achieve?


    Please remember to click "Mark as Answer" or "Vote as Helpful" on the post that answers your question (or click "Unmark as Answer" if a marked post does not actually answer your question). This can be beneficial to other community members reading the thread.


    This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

    Twitter: @stealthpuppy | Blog: stealthpuppy.com | The Definitive Guide to Delivering Microsoft Office with App-V

    Tuesday, November 20, 2012 11:19 AM
    Moderator
  • Yes, you are right.

    There is one .exe that uses a .ini for configuration. A different .ini needs to be copied in place depending upon application backend server they want to connect to.

    In App-V 4.6 I used .osd pre-launch scripts to do this. I'm trying to achieve the equivalent in App-V 5.

    Tuesday, November 20, 2012 3:00 PM
  • Hi,

    We opened a case with MS asking how to use the equivalent of the AppV 4.6 pre-launch scripts (osd scripts), in AppV 5.0.

    The result of the case is that the use of these scripts has effectively been dropped in App-V 5.0:

    "...this behavior is by design.
     
    App-V 5.0 is designed to behave more in line with native application installations.
    The side benefit we had in versions before 5.0 is lost because of this. "

    Unbeliveably we are going to have to do something like modify our shortcuts to point to batch files to carry out pre-launch commands and then call the .exe.

    Is this progress?

    • Marked as answer by StuHed Monday, December 17, 2012 4:02 PM
    Monday, December 17, 2012 4:02 PM
  • Shocking!
    Monday, December 17, 2012 4:07 PM
  • So, what would be the working equivalent of setup I used to have in 4.6:

    App Test

    App Pre-Prod

    App Prod

    Same app.exe with different scripts executing to copy over files.

    Wednesday, March 13, 2013 2:27 PM
  • We have the same use case where we publish ~15 osd's, each with a different registry key (a connection string).

    Works very well in 4.x, but I think we may be in the same situation as you here... Have you been able to find a better solution than to publish bat files with reg scripts? And if not I would love some input on how you ended up solving it.

    I haven't really delved into UserConfig.xml and the possibilities there, but it seems to me that any group-membership-based adaptations to the package has to be applied through a script that does the group-matching and reg-tweaking, and that all users have to run.

    I don't really see why this feature had to go... Much cleaner and easier to maintain in separate OSD's. (or so it seems at this early stage)

    Tuesday, March 26, 2013 2:53 PM
  • Answering my own question for any future googlers, since I don't think the current answer is the best for all/our use case:

    The answer is found here in the official documentation: http://technet.microsoft.com/en-us/library/jj713407.aspx

    Basically instead publishing to different osd's for the same app for our different groups of users, we publish the same app and differentiate the groups by creating multiple User_config.xml-files that are linked to the different AD-groups in the management console (see documentation).

    Amazing what you can find if you just RTFM! :)

    • Proposed as answer by HelloWorld51 Thursday, March 28, 2013 12:39 PM
    Wednesday, March 27, 2013 11:09 AM
  • Hello Stuhed, For me the userscripts itself is not working :( .. tried almost all the cases. I want to run one vbs file on prelaunch of shortcut. so, I m using Startprocess under Userscripts. the code is below: This I've added in DeploymentConfig.xml but not luck after many attempts. I tried with Scriptrunner as well. Please help.

    <UserScripts>

         <StartProcess RunInVirtualEnvironment="true">
            <Path>%SYSTEMROOT%\System32\CSCRIPT.EXE</Path>
            <Arguments>VFS\AppVPackageDrive\temp\Test1.vbs</Arguments>
            <Wait RollbackOnError="true"/>
            <ApplicationId>[{ProgramFilesX86}]\Testing\Test2.vbs</ApplicationId>
         </StartProcess>

    </UserScripts>

    I'm looking for your help on this. Thank you in advance.

    Wednesday, March 29, 2017 10:04 AM
  • If deployed to users, put it in the userconfig.xml under userscripts. Make sure running scripts is enabled.

    Also, put the script in the "script" folder in your package and change the argument to "Test1.vbs". The working-dir for running scripts is by default the script-folder. 


    Roy Essers

    Wednesday, March 29, 2017 5:50 PM
  • Have you tried in domain joined machines as user scripts will only run on them and not in local account. Have you checked whether the script is getting triggered at first?Have you tried setting rollbackonerror to false to see the issue whether the script fails? Have you looked into eventlog for script execution status? 

    Is the ApplicationID tag correct? It should point to the respective shortcut ID for which you want to run the script prior.

    Check this - https://blogs.technet.microsoft.com/appv/2012/12/10/scripting-and-embedded-scripting-for-appv-5-0-dynamic-deployment-and-user-configuration-scripting/

    https://blogs.technet.microsoft.com/appv/2014/01/30/how-to-troubleshoot-app-v-5-0-deploymentconfig-userconfig-script-deployment-failures-using-appv-manage/


    (Please click on Vote as Helpful and/or Mark as Answer, if it has helped you.)

    MVP - Windows and Devices for IT

    app2pack.blogspot.com: app2pack.blogspot.com

    Friday, March 31, 2017 12:20 PM