locked
COM Object - Multiple Processes RRS feed

  • Question

  • Hi,

    I'm converting a HFSS vbs script file to VB .NET and almost done except for 1 problem. Below code shows what I'm doing. Start hfss.exe, create the com object, send scripts to program and quit. It works fine unless another hfss window is already open. So, my 1st line creates a 2nd hfss.exe in taskbar, but com object refers to the 1st hfss.exe which is already open and new project created under that window. Is there a way to force com object to the 2nd one (or any specific process when there are multiple of them)?   

    Thanks,

    EF

    myproc = System.Diagnostics.Process.Start("C:\Program Files (x86)\Ansoft\HFSS13.0\hfss.exe")
    oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
    oDesktop = oAnsoftApp.GetAppDesktop()
    oProject = oDesktop.NewProject
            
    '...Scripts Here...'
    oProject.close()
    oDesktop.QuitApplication()
    myproc.Kill()

    Tuesday, July 31, 2012 3:48 PM

Answers