locked
Running a BAT or VBS file outside of the bubble - AppV 5.0 DeploymentConfig.XML Scripting RRS feed

  • Question

  • Hi

    I am fairly new to App-V 5.0 and am trying to understand launching scripts from the DeploymentConfig.xml file.

    The requirements I have are as follows:

    Set a new entry in the Passthrough key at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\AppV\Subsystem\VirtualRegistry

    <MachineScripts>     

    <PublishPackage>
            <Path>wscript.exe</Path>
            <Arguments>[{AppVPackageRoot}]\..\Scripts\UpdatePassThroughPaths.vbs</Arguments>
            <Wait RollbackOnError="true" Timeout="30"/>
          </PublishPackage>

    </MachineScripts>

    This works fine.  I guess I could add it to the AddPackage event, not sure what the advantage would be?

    However I also need to run a bat or vbs (would be better) file every time the application is launched.  There will also be an ExitProcess event triggered too, but I am trying to get the Startprocess to work.

    Here is an extract of the DeploymentConfig.xml file:

        <UserScripts>
          <StartProcess RunInVirtualEnvironment="false">
            <Path>cmd.exe</Path>
            <Arguments>/C C:\temp\test.bat</Arguments>
            <Wait RollbackOnError="true"/>
            <ApplicationId>[{ProgramFilesX64}]\some.exe</ApplicationId>
          </StartProcess>
       </UserScripts>

    I have written a test batch file that should write a registry key in HKCU as that is what my script will do, but it does not appear to work inside or outside the "bubble".  Am I missing something, doing something wrong?


    • Edited by SteveWeaver Monday, August 3, 2015 12:31 PM Typo
    Monday, August 3, 2015 12:29 PM

Answers

  • Here below is my DeploymentConfig which I've tested & it created a key under HKCU,

    Have you tested your .BAT File manually & see if that work as expected?

    I would suggest to use ACE to edit the XML. You just have to Install the exe which is of 1 MB. Launch the shortcut & browse the XML File & you can do the rest using the UI.

    Also, User Scripts won't work with Local Accounts. You have to login using Domain Account for the user scripts to run.

    Monday, August 3, 2015 1:33 PM
  • No, ACE is not from Microsoft. You can find it HERE.
    Monday, August 3, 2015 3:57 PM

All replies

  • Here below is my DeploymentConfig which I've tested & it created a key under HKCU,

    Have you tested your .BAT File manually & see if that work as expected?

    I would suggest to use ACE to edit the XML. You just have to Install the exe which is of 1 MB. Launch the shortcut & browse the XML File & you can do the rest using the UI.

    Also, User Scripts won't work with Local Accounts. You have to login using Domain Account for the user scripts to run.

    Monday, August 3, 2015 1:33 PM
  • Hi tested the batch file manually and all works fine.

    Thanks for the ACE tool recommendation, is that a Microsoft tool?

    I am not in a domain, so that must be my problem.  I will report back with an update once a get a test image created.

    Monday, August 3, 2015 2:55 PM
  • No, ACE is not from Microsoft. You can find it HERE.
    Monday, August 3, 2015 3:57 PM
  • Here below is my DeploymentConfig which I've tested & it created a key under HKCU,

    Also, User Scripts won't work with Local Accounts. You have to login using Domain Account for the user scripts to run.

    It was indeed the local account.  Everything working fine now.  Although have to run the script from outside the "bubble".

    Thank you for your help.

    Is there a document that explains when UserScripts/MachineScriipts events are triggered etc.



    • Edited by SteveWeaver Monday, August 3, 2015 10:37 PM
    Monday, August 3, 2015 10:37 PM
  • Check the following ->

    Tim
    Technet
    Gladiator


    • Edited by Roy Essers Monday, August 3, 2015 10:44 PM
    Monday, August 3, 2015 10:44 PM
  • Thank you.
    Tuesday, August 4, 2015 10:46 AM
  • Check the following ->

    Tim
    Technet
    Gladiator


    Hi

    Just been doing some further testing. And my requirement is to launch a VBS file, which must be run outside of the “bubble”.  The file is located at ”C:\Temp\test.vbs" and should only be launched when a specified shortcut (exe) is launched.   This is the script I am currently using which works.

    As below:

    <StartVirtualEnvironment>
    <Path>cmd.exe</Path>
    <Arguments>/C "C:\Temp\test.bat"</Arguments>
    <Wait RollbackOnError="true"/>
    </StartVirtualEnvironment>
    </UserScripts>

    This event appears to launch the VBS file when ANY of the shortcuts are launched - this not the behaviour I want.

    So I tried:

    <StartProcess RunInVirtualEnvironment="false">
    <Path>wscript.exe</Path>
    <ArgumentsC:\Temp\test.vbs"</Arguments>
    <Wait RollbackOnError="true"/>
    <ApplicationId>[{AppVPackageRoot}]\VFS\[{ProgramFilesX64}]\some.exe</ApplicationId>
    </StartProcess>

    I would assume that the location of the script needs to be located outside of the "bubble" for the script to work anyhow as it doesn't work when run in the VE as I mentioned above.  Additionally, I set  RunInVirtualEnvironment="false"

    Neither worked.

    Am I misinterpreting how the events are supposed to work?

    Thanks


    Sunday, August 9, 2015 9:38 PM
  • Any help on the above?

    Many thanks.

    Tuesday, August 11, 2015 9:57 PM
  • Tested your scenario in my test home lab. Here is my input.

    I placed a script named test.vbs which contains the below codes to open up a notepad text.txt file in C:\Temp

    Dim oShell
    Set oShell = WScript.CreateObject ("WScript.Shell")
    oShell.run "notepad.exe c:\text.txt"
    Set oShell = Nothing

    Sequenced a test app. Edited the userconfig.xml file and placed a script to launch this test.vbs when I launch my shortcut.(Note multiple shortcuts are there, but I have used this for a single one only)

    The script part in userconfig below.

     <UserScripts>
         <StartProcess RunInVirtualEnvironment="false">
         <Path>wscript.exe</Path>
         <Arguments>C:\Temp\test.vbs</Arguments>
         <ApplicationId>[{AppVPackageRoot}]\Reader\test1.exe</ApplicationId>
         </StartProcess>
    </UserScripts>

    Now testing part. Enabled execution policy to unrestricted. Enabled scripts to true.

    Added and published the package with the userconfig file.

    Note: while publishing use -DynamicUserConfigurationPath "path to userconfig"

    when I launched the test1.exe. I faced the below error.

    Ok, what next. Tried to resolve the issue.

    The error code 534 in hex (1332 decimal. check this link for details about the error code.

    http://www.tmurgent.com/TMBlog/?p=1857

    http://packageology.com/2014/03/user-scripts-broken-app-v-5-0-sp2-local-accounts/

    User scripts will fail for local accounts. Hence I Logged on with a domain account and repeated the same steps.

    viola!! when I launched the shortcut, the script ran and opened the text.txt file. 

    Hope this will give you an answer.


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

    Wednesday, August 12, 2015 6:21 AM
  • The second script in your previous thread is incorrect. Correct one below.

    <StartProcess RunInVirtualEnvironment="false">
    <Path>wscript.exe</Path>
    <Arguments>C:\Temp\test.vbs</Arguments>
    <ApplicationId>[{AppVPackageRoot}]\VFS\[{ProgramFilesX64}]\some.exe</ApplicationId>
    </StartProcess>

    The Arguments tag has a missing >

    Try now and let us know.


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

    Wednesday, August 12, 2015 8:08 AM