locked
Issue with cscript/wscript breaking outside the AppV 5 bubble when run inside the bubble. RRS feed

  • Question

  • I'm working on sequencing an application (EPIC) and they have a debugging script that runs that executes their application and their debugging application immediately afterwards with some parameters.  When I try running this script inside the AppV 5 bubble from a command prompt it fails.  I've found the issue appears to be that cscript and wscript are looking for the registry values it requires outside the bubble.  I've shortened their script and the registry key required to minimize the noise of this problem.  The VBS script is:

    '========================================================

    Dim sEpicInstall, oCtx, oFSO, oReg, oLocator, oServices, oInstallDrive

    Const HKEY_LOCAL_MACHINE = &H80000002

    Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
    Call oCtx.Add("__ProviderArchitecture", 32)
    Call oCtx.Add("__RequiredArchitecture", TRUE)

    Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
    Set oServices = oLocator.ConnectServer(".","root\default", , , , , , oCtx)

    Set oReg = oServices.Get("StdRegProv")
    Call oReg.GetStringValue(HKEY_LOCAL_MACHINE, "SOFTWARE\Epic Systems Corporation\Install", "79", sEpicInstall)
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set oInstallDrive = oFSO.GetDrive(oFSO.GetDriveName(sEpicInstall))

    '===========================================================

    The registry key that exists inside the bubble looks like so:

    ===========================================================

    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Epic Systems Corporation\Install]
    "79"="C:\\Program Files (x86)\\Epic\\v7.9"

    ===========================================================

    if run inside the bubble this is the result I get:

    If I add the registry key to the system itself and execute the command outside the bubble it works without issue:

    So...  I'm assuming this is a bug in AppV 5?  Is there a reason why cscript/wscript can break outside the environment or is there a reason why this script is able to do so?

    Thursday, November 6, 2014 5:30 PM

Answers

  • Indeed, the WMI Service runs outside  of App-V. Therefor using WMI to  access your registry will always be outside the bubble. Afaik appv4 and appv5 handle this the same way.
    If you have to use vbscript, just use shell and RegRead to get the data.
    Thursday, November 6, 2014 10:15 PM
  • Agreed with the above. If you use WMI, you are asking a process already running outside of the bubble to do your bidding. I'm pretty sure it was Kalle who pointed this out way back, I can't find the article I'm thinking of but it inspired him to write this tool which lets you launch processes outside of the VE:

    http://blog.gridmetric.com/2011/11/21/exitve-an-escape-hatch-from-the-app-v-virtual-environment


    Friday, November 7, 2014 1:48 PM
  • Here is a really interesting article about running cmd/bat and vbs with App-V 5

    http://packageology.com/2013/06/launching-reg-bat-cmd-vbs-files-app-v-5/

    However, what is interesting is you are invoking WMI in your vbs.  I have read somewhere (and I apologize I can't remember where) that doing WMI calls will ALWAYS end up outside the bubble.  For kicks, can you modify the vbs to do WshShell.RegRead / RegWrite instead?  Its been on my to-do list for months to write a reproducer to test myself, I'll try to do that soon also.

    Did this work in App-V 4?  Curious if it is something with App-V 5 vs 4 or just virtualization in general.


    Thursday, November 6, 2014 6:03 PM

All replies

  • Here is a really interesting article about running cmd/bat and vbs with App-V 5

    http://packageology.com/2013/06/launching-reg-bat-cmd-vbs-files-app-v-5/

    However, what is interesting is you are invoking WMI in your vbs.  I have read somewhere (and I apologize I can't remember where) that doing WMI calls will ALWAYS end up outside the bubble.  For kicks, can you modify the vbs to do WshShell.RegRead / RegWrite instead?  Its been on my to-do list for months to write a reproducer to test myself, I'll try to do that soon also.

    Did this work in App-V 4?  Curious if it is something with App-V 5 vs 4 or just virtualization in general.


    Thursday, November 6, 2014 6:03 PM
  • Indeed, the WMI Service runs outside  of App-V. Therefor using WMI to  access your registry will always be outside the bubble. Afaik appv4 and appv5 handle this the same way.
    If you have to use vbscript, just use shell and RegRead to get the data.
    Thursday, November 6, 2014 10:15 PM
  • Thanks for the confirmation Tiberivs.
    Friday, November 7, 2014 1:45 PM
  • Agreed with the above. If you use WMI, you are asking a process already running outside of the bubble to do your bidding. I'm pretty sure it was Kalle who pointed this out way back, I can't find the article I'm thinking of but it inspired him to write this tool which lets you launch processes outside of the VE:

    http://blog.gridmetric.com/2011/11/21/exitve-an-escape-hatch-from-the-app-v-virtual-environment


    Friday, November 7, 2014 1:48 PM
  • Hi All,

    I'm using the below script to launch IE with addressbar disabled and also to have it as the first window when the shortcut is launched. My URL requires Java and hence it has been included in the virtual package.

    'On Error Resume Next
    Const navOpenInNewWindow=1
    Set WshShell = Wscript.CreateObject("Wscript.Shell")
    Set ObjIE = Wscript.CreateObject ("IntenetExplorer.Application")

    ObjIE.Menubar = 1
    ObjIE.Toobar = 0
    ObjIE.statusbar = 0
    ObjIE.Navigate ("www.google.com",1)
    ObjIE.visible = 1
    WshShell.AppActivate objIE.Document.Title

    This VBS script is the target of my shortcut and is launched in the VE using the appvve switch. But my Internet explorer does not launch in VE as my Java plugins are not loaded in the IE. Please let me know how to handle it?

    Tuesday, December 9, 2014 1:19 PM
  • You should probably start a new thread for this as it's a new question, and a different problem than the original post.

    I have not tried the above, but have you made sure IE is closed before running it? If IE is already running outside of the bubble when you run the script, it could use the existing IE process rather than create a new one inside the bubble.

    As far as I know, .vbs files should run inside the bubble unlike cmd/bat files when targeted directly by the shortcut. But it is worth trying modifying the shortcut to point to wscript.exe with the script supplied as a parameter, just to rule it out.

    Another option to look into is to target your shortcut to iexplore.exe directly, and apply the changes to hide the toolbar and status bar either via additional command line parameters, or via registry configuration if this is possible.


    Tuesday, December 9, 2014 1:28 PM
  • Hi Dan,

    I have ensured that IE is not launched while launching my shortcut.

    I have tried pointing the shortcut to wscript.exe/cscript.exe and the passing the target vbs as arguments but of no help.

    Command line options are not flexible enough to help me out. Registry changes are the only option left behind.


    • Edited by Azhar_M Tuesday, December 9, 2014 1:53 PM
    Tuesday, December 9, 2014 1:38 PM