VMware Horizon Community
MrBeatnik
Hot Shot
Hot Shot

OnFirstParentStart WMI/GetObject Error

Hi folks.

I'm having some issues when running a particular line of code in a ThinApp VBS.

The code works for me fine on its own, but not inside a ThinApp package.

I was curious if it may be some ThinApp settingfor the package, as it appears that others do not have a problem with this.

You can see some sample code here which does not work for me:

http://www.horizonflux.com/thinapp-scripting-launch-virtual-application-only-if-a-specific-process-i...

The particular error is:

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

As I said, the code works fine on it's own outside of a ThinApp application, and since this is being published on other sites I assume it works correctly inside ThinApp applications for other people.

Any help you can give would be appreciated!!

Thanks.

The package.ini is as follows for this app:

[Compression]
CompressionType=None
[Isolation]
DirectoryIsolationMode=Merged
[BuildOptions]
;-------- MSI Parameters ----------
;Enable MSIFilename if you want to generate a Windows Installer package.
;MSIFilename=Arena301.msi
;MSIManufacturer=Unknown
;MSIProductVersion=1.0
;MSIDefaultInstallAllUsers=1
;MSIRequireElevatedPrivileges=1
;MSIInstallDirectory=Arena301 (VMware ThinApp)
;MSIProductCode={9CB35312-287A-DF71-B51D-27AAF49B8EEE}
;MSIUpgradeCode={C65B8CD8-A8FF-1CC5-1420-9F8E3BC68BCF}
;MSIStreaming=0
;MSICompressionType=Fast
;MSIArpProductIcon=%AppData%\Microsoft\Installer\{7CCBDAB6-9F93-4C2C-BF01-1D40A3335180}\ARPPRODUCTICON.exe
;-------- AppSync Parameters ----------
;AppSyncUpdateFrequency=1d
;AppSyncExpirePeriod=30d
;AppSyncWarningPeriod=5d
;AppSyncWarningFrequency=1d
;AppSyncWarningMessage=This application will become unavailable for use in %remaining_days% day(s) if it cannot contact its update server. Check your network connection to ensure uninterrupted service.
;AppSyncExpireMessage=This application has been unable to contact its update server for %expire_days% day(s), so it is unavailable for use. Check your network connection and try again.
;AppSyncUpdatedMessage=
;AppSyncClearSandboxOnUpdate=0
;-------- Parameters used only during Setup Capture  ----------
AccessDeniedMsg=You are not currently authorized to run this application. Please contact your administrator.
CapturedUsingVersion=4.7.2-771812
OutDir=bin
;-------- General Purpose Parameters  ----------
SandboxName=Arena301
InventoryName=Arena301
InventoryIcon=%AppData%\Microsoft\Installer\{7CCBDAB6-9F93-4C2C-BF01-1D40A3335180}\ARPPRODUCTICON.exe
;PermittedGroups=Administrators;Remote Desktop Users
;RemoveSandboxOnExit=1
;RemoveSandboxOnStart=1
;SandboxNetworkDrives=1
;SandboxRemovableDisk=1
;VirtualizeExternalOutOfProcessCOM=0
;OptionalAppLinks=plugins\*.exe
;RequiredAppLinks=\\server\share\*.exe;c:\abs\path\file.exe
VirtualDrives=Drive=c, Serial=58e2f0af, Type=FIXED
;VirtualDrives=Drive=a, Serial=0012d294, Type=REMOVABLE; Drive=c, Serial=58e2f0af, Type=FIXED; Drive=d, Serial=58e2f0af, Type=CDROM
;VirtualComputerName=WIN-TRK2TDBBJEU
AnsiCodePage=1252
LocaleIdentifier=1033
LocaleName=en-US
; If you have problems running a 32 bit application under 64 bit Windows, try enabling this line before building the project
;Wow64=0
; Enable this option to load .Net binaries from the system instead of the package on Windows 7
;LoadDotNetFromSystem=Win7
QualityReportingEnabled=0
; Enable this option to ignore DDE messages from external processes
;IgnoreDDEMessages=1

Reply
0 Kudos
10 Replies
oliAH
Enthusiast
Enthusiast

The particular error is:

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

As I said, the code works fine on it's own outside of a ThinApp application, and since this is being published on other sites I assume it works correctly inside ThinApp applications for other people.

The script is fine but it seems like you have an issue with the double quotes. Probably due to a copy/paste from a website.

Please replace them by the double quote you can find on your keyboard.

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Blog: http://oliah.net >> Twitter: @olivier_ahson
Reply
0 Kudos
MrBeatnik
Hot Shot
Hot Shot

The code in my script has regular double quotes. The particular line in my post above that you reference is copied directly from the website using clipboard, hence why the quotes are a little different, but that is not the case on the actual code in the script.

As said, the script works fine outside of ThinApp; a simple syntax error as the incorrect double quote character would make it fail outside of ThinApp (invalid character error), but that is not the case.

It appears to be ThinApp that is causing the issue in some way.

Reply
0 Kudos
oliAH
Enthusiast
Enthusiast

Just tried this piece of code with a CMD only ThinApp project (4.7.3) and it worked fine for me.

I just replaced 'saplogon.exe' by 'notepad.exe' and added a Else with a msgbox for the sake of testing.

' Run script if an entry point is launched
Function OnFirstParentStart

    ' Initialize variables
    Dim objWMIService, objWMIProcess, objShell
    Dim colWMIProcess
    Dim strTitle, strMessage, strComputer, strProcess
    Dim intButton

    ' Set computer to localhost
    strComputer = "."
    ' Set process to check
    strProcess = "notepad.exe"

    ' Set error message
    strTitle = "VMware ThinApp"
    strMessage = "The process " & strProcess & " is already running!" & Vbcrlf & "Please close the process and then try again."
    intButton = 48

    ' Connect to WMI service
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colWMIProcess = objWMIService.ExecQuery("Select * from Win32_Process Where Name='" & strProcess & "'")
    If colWMIProcess.Count > 0 Then
        ' Display message box
        Msgbox strMessage, intButton, strTitle
        ExitProcess 0
    Else
        ' Display message box
        Msgbox strProcess & " is not running!"       
        ExitProcess 0
    End If

' End of OnFirstParentStart Function
End Function

Make sure you are saving this piece of code with notepad and ANSI Encoding (by default it's ANSI but just to make sure...).

JuJust
Blog: http://oliah.net >> Twitter: @olivier_ahson
Reply
0 Kudos
MrBeatnik
Hot Shot
Hot Shot

There seems to be a little confusion here.

There is nothing wrong with the script; it works perfectly outside of ThinApp.

Instead, there appears to be an issue when including it inside ThinApp.

Any incorrect formatting, syntax errors etc, would manifest outside of ThinApp, as far as I am aware. Just to be absolutely sure, I have made sure that it was saved with notepad etc, etc but of course the problem persists.

I would regard myself as a veteran VBScripter, for what it's worth, and have not had problems including scripts in ThinApp in the past. However, I have not attempted to query WMI in a ThinApp script before. I am aware that there are limitations (as mentioned, WSCRIPT for example).

Since it works for you, I am guessing it may be a ThinApp setting, hence why I posted my INI settings. I guess it could be a problem with the ThinApp version (4.7.2-771812). Would it be possible for you to post the package.ini file for the test you performed?

I do appreciate your help.

Reply
0 Kudos
oliAH
Enthusiast
Enthusiast

As far as I remember, I've done a few ThinApp scripts with 4.7.2 involving WMI queries and never had any issue.

I sent you the link of the project in private message. Hope you'll get it to work!

Blog: http://oliah.net >> Twitter: @olivier_ahson
MrBeatnik
Hot Shot
Hot Shot

Thank you for the example.

That works fine.

> I rebuilt it on my machine and it still works.

> I copied my VBS into it, and that also works.

So, for some reason, the ThinApp project I am using is having issues with the script.

The actual application works fine, but I guess there must be something interfering somwhere. I'll try with some other packages and maybe retry a capture... but very strange. After a quick comparison of your package.ini and mine, it all looks similar.

I even updated to 4.7.3 to rebuild, but still no  joy.

In the mean time, if anyone has more suggestions I would be very happy to try them.

Reply
0 Kudos
oliAH
Enthusiast
Enthusiast

If it's a project you can share, I'd gladly have a look at it.

Blog: http://oliah.net >> Twitter: @olivier_ahson
Reply
0 Kudos
MrBeatnik
Hot Shot
Hot Shot

I have recaptured the project, and it's now working as expected.

Looks like there are a couple of projects that I was testing this script with that have this problem. Not sure exactly why this is the case; it could have something to do with the rebuilds from a much previous version of ThinApp that has screwed up something internal to the project.

Anyway, it means that I have to recapture a load of apps (and we have a lot!), but hey - it'll keep me busy Smiley Happy

Thanks for sticking with me, it helped!!

Reply
0 Kudos
MrBeatnik
Hot Shot
Hot Shot

Very strange...

I thought the problem was resolved with a recapture, but I am getting this problem again on some packages after recapture too.

The problem only appears on some packages. I am using the same clean machine for all my packaging.

Very strange with one package that has two entry points:

> One entry point works fine, runs the VBS and throws no errors.

> Other entry point throws the error.

Reply
0 Kudos
oliAH
Enthusiast
Enthusiast

Is there a project among them you can share? If so, you can send it to me by pm.

Blog: http://oliah.net >> Twitter: @olivier_ahson
Reply
0 Kudos