vb.net program launchs and then closes automatically
Posted on 2011-10-25
I have developed a vb.net program which when run from a shortcut works fine, however when I run it through an older vb6.exe which uses the winapi Shell Execute function, the program briefly appears on the screen and then closes. This also happens with a piece of third party software that is setup to run this program.
Developed in Visual Studio 10, vb.net, this happens on Windows 7 and Xp workstations. The program is configured as a Windows Form Application.
Would appreciate any help
vb6 code that does the shell to the vb.net exe
' First, create a known, temporary HTML file
exeName = Space(255)
retval = FindExecutable(FileName, Dummy, exeName)
exeName = Trim(exeName)
' If an application is found, launch it!
If retval <= 32 Or IsEmpty(exeName) Or Err Then ' Error
LaunchFile = False
FileName = quo(FileName) 'put quotes around the item
retval = ShellExecute(frmIcon.hwnd, "open", Trim$(exeName), FileName, Dummy, 5)
If Err <> 0 Then
MsgBox "Unable to run program <" & exeName & "> and launch file <" & FileName & "> RetVal=<" & CStr(retval) & "> Error=<" & Error$ & ">"
LaunchFile = True