ThinApp Scripting: Launch virtual application only if a specific process is not running

In my daily life as Consultant for VMware I implement a lot of customer specific scripts using the ThinApp scripting engine and I just thought: Why not share these scripts?

The following script can be used if a ThinApp application can or should not be launched if a specific process is already running. In this particular case a virtualized instance of SAP should only be able to launch if no native instance of SAP is running already.

To implement this script in your ThinApp project just save the code above as .vbs file in your ThinApp projects folder und customize the variable strProcess. Just enter the process you want to check and you are ready.
You can also customize the error message the user gets by modifying the variable strMessage.

6 comments » Write a comment

  1. Pingback: ThinApp Scripting: Launch virtual application only if a specific process is not running at That's my View

  2. When possible, you should do your login right in your WMI query. In this case the following changes will make the script return much faster on a system with lots of processes running:


    [22] Set colWMIProcess = objWMIService.ExecQuery("Select * from Win32_Process Where Name='" & strProcess & "'")
    [23] If colWMIProcess.Count > 0 Then
    [24] ' Display message box
    [25] Msgbox strMessage, intButton, strTitle
    [26] ExitProcess 0
    [27] End If
    [28] ' End of OnFirstParentStart Function
    [29]End Function

    • LOGIC, not LOGIN.. /sigh

      Sorry that should have read “..you should do your LOGIC right in your…”

    • Hi Jorgie, thanks for your tip. You are right, your code is much more efficient and therefore I updated the post with it. Thanks, much appreciated. I actually used the original script logic to check for more than one process and modified it to work with just one process. It seems I forgot to optimize the script afterwards! ;)

  3. This doesn’t work for me…

    The script works fine when run individually (assuming you call the function first), but when it is compiled and run from the ThinApp’d application, an error message appears. I’m wondering if the WMI object will only work if the application is ThinApp’d with specific settings (perhaps changing isolation mode)?

    Error Line 21, Char 1: Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2″)
    Source: Microsoft VBScript Runtime Error
    Description: Object Required: ‘objWMIService’

    It seems that GetObject is not returning correctly, but only when run inside…

    • I just tested the script again with ThinApp 4.7.3 on a Windows 7 host and it worked without any problem. I haven’t set any specific isolation mode.

Leave a Reply

Required fields are marked *.


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">