Quantcast
Viewing all articles
Browse latest Browse all 240675

Re: OnFirstParentStart WMI/GetObject Error

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

Viewing all articles
Browse latest Browse all 240675

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>