• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

vb.net program launchs and then closes automatically

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
Else
    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$ & ">"
    Else
        LaunchFile = True
    End If
End If
0
nobleone
Asked:
nobleone
  • 6
  • 2
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
What is in "Dummy"?  You may need to pass in the working directory instead (often the path to the executable itself) for the app to work correctly.
0
 
nobleoneAuthor Commented:
Dummy is empty string...good point, I am going to try changing that and see if it works...will get back to you
0
 
nobleoneAuthor Commented:
I solved the problem....the code was using application.run to run the first form from the  Sub Main used on startup as recommended in reading I did.  When run from a shortcut on desktop no problem, when shelled in any way, causes the program to self terminate.  I changed this to  form.showdialog method and it solved the problem.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Why is it using Sub Main()?  If you need an earlier entry point, use the Application.Startup() event.
0
 
nobleoneAuthor Commented:
vb6 conversion is why,   had about 800 properties, ocx , etc changes, definitely a learning experience...but vb.net is much better than the old vb6..thats for sure...did not know about the application.startup...I've been a sub main guy from years back...suspect that would have solved this problem also.  
0
 
nobleoneAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for nobleone's comment http:/Q_27414103.html#37104441

for the following reason:

was not the solution, but appreciated the very prompt input
0
 
nobleoneAuthor Commented:
mistake in the clicking...I wanted to close and award to idle_mind...was on my comment when I clicked close by accident, can you please award him the points...thanks
0
 
nobleoneAuthor Commented:
Not the exact solution, but would have solved the issue also
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now