?
Solved

How can I launch a VB.NET 2005 exe from a vb6 exe?

Posted on 2007-08-07
25
Medium Priority
?
588 Views
Last Modified: 2013-11-26
Is there a way for me to launch a VB.NET 2005 exe from a vb6 exe?

I created a stand-alone vb.net 2005 app.  I built it.  I installed it using ClickOnce.
It created all the subdirectories and burried it somewhere deep within my system.
It also created an "Application Reference" in the Start - Programs menu.
I cannot figure out how to accss this application from code in vb6.

I tried

dim NetApp as long
NetApp = Shell("C:\Documents and Settings\MyComp\Start Menu\Programs\NetApp\NetApp", vbMaximizedFocus")
but that doesnt work.  it says the file cannot be found.

I cannot hard code the exe's location in the vb6 app because it installs to a different folder on everyone's PC.

Does anyone know how to do this? Is it possible?  
I dont need to use any variables or any data from the .NET app in the vb6 exe, i just need to launch it.
0
Comment
Question by:fesit
  • 9
  • 8
  • 5
  • +2
25 Comments
 
LVL 27

Expert Comment

by:VBRocks
ID: 19646020
Is NetApp the name of the app?  It should have a ".exe" or something after it.

0
 
LVL 33

Expert Comment

by:hongjun
ID: 19646097
You can use this

System.Diagnostics.Process.Start("C:\Documents and Settings\MyComp\Start Menu\Programs\NetApp\NetApp\yourprogram.exe")

hongjun
0
 
LVL 6

Expert Comment

by:hatem72
ID: 19646159
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 33

Expert Comment

by:hongjun
ID: 19646185
To make it maximized, try this

I assume you have import the below namespace

Imports System.Diagnostics
'''''
'''''

Dim startInfo As New ProcessStartInfo()
startInfo.FileName = "C:\Documents and Settings\MyComp\Start Menu\Programs\NetApp\NetApp\yourprogram.exe"
startInfo.WindowStyle = ProcessWindowStyle.Maximized
Process.Start(startInfo)


hongjun
0
 

Author Comment

by:fesit
ID: 19646243
Thank you both for the quick replies...but.....

System.Diagnostics.... didnt work.
I am trying launch it from vb6.  
I get method or data member not found, talking about the .Diagnostics part

"NetApp" is the name of the application.
But in the Start Menu - the .exe is not there.
Only an "Application Reference"
There is no extension after it.
It's weird.  I had a Shortcut renamed to "NetApp" in my C: drive.  I created the shortcut from the burried folder that contains the acutal NetApp.exe.
Then I copied the Application Reference from the start menu, also named "NetApp" (same as shortcut) - and pasted it into the C: drive.  It did not give me a naming conflict.  I was able to paste it there.  Both files existed with the same name - NetApp the shortcut, and NetApp the Application Reference.

So bottom line, I still cant launch the .NET app from vb6.
.....need.............more............................help......


0
 
LVL 33

Expert Comment

by:hongjun
ID: 19646280
VBRocks has pointed out.
There's no file extension.

hongjun
0
 
LVL 33

Expert Comment

by:hongjun
ID: 19646330
try this

NetApp = Shell("C:\Documents and Settings\MyComp\Start Menu\Programs\NetApp\NetApp.exe", vbMaximizedFocus)

I notice you have an extra " at the very end.

hongjun
0
 
LVL 27

Expert Comment

by:VBRocks
ID: 19646354
For one thing, you don't want to use the following, because it is the path to the Shortcut, not the actual
exectuable itself:
    "C:\Documents and Settings\MyComp\Start Menu\Programs\NetApp\NetApp"

Open explorer and navigate to the "NetApp.exe" file, then copy the full path to the file.  So it should be
something like:
    "C:\C:\Program Files\NetApp\NetApp.exe"


You can also just right-click on the Shortcut and go to Properties, then look at the Target path, and that's
what you'll want to use.

0
 

Author Comment

by:fesit
ID: 19646448
I have to look more into that Inerop article.
Not sure if that can help me.

There is no file extension because the Application Reference does not have a file extension.
If i reference the shortcut, it works.  If i reference the actual exe, it works.
The problem with that is that the exe installs itself into a different directory on every PC it's installed on.
So I'd either have to hard code every exe specifically to everyone's own PC, which obviously cannot happen - or go around to everyones pc and manually create a shortcut in a directory that will be static for every user so i can at least hardcode that in vb6 - but that is not efficient either.

In case nobody knows the type of directory the actual exe gets installed in, the fully qualified path looks like this:
C:\Documents and Settings\MyComp\Local Settings\Apps\2.0\3004N2YP.8N0\5QX730G9.KLO\enti..tion_29d115623927c249_0001.0000_3afb06197d05839c\NetApp.exe

after the ....\2.0\ folder, the rest of that changes on every PC its installed on

the shell command is not working - (the extra quote was just a typo when posting on here because i wrote it out instead of copying and pasting) - the application reference does not have an .exe extension.  it says the file cannot be found
0
 
LVL 33

Expert Comment

by:hongjun
ID: 19646498
It looks more like a click once application.

hongjun
0
 

Author Comment

by:fesit
ID: 19646521
It is a ClickOnce application - I had posted that in my original question.

How does that help/hurt the situation?  This is the first time i deployed anything in .NET.  
0
 
LVL 27

Expert Comment

by:VBRocks
ID: 19646552
You're right, that's exactly what ClickOnce deployment does.  

Is there a set location where the ClickOnce application is being launched from that you can reference,
or does that location change as well?

0
 

Author Comment

by:fesit
ID: 19646583
What do you mean when you say where it is being "launched" from - the install directory?
the install/update directory is always the same.
but when the user installs it on their own pc, the directory of where the actual .exe is getting installed is in different folders.
like in this example
C:\Documents and Settings\MyComp\Local Settings\Apps\2.0\3004N2YP.8N0\5QX730G9.KLO\enti..tion_29d115623927c249_0001.0000_3afb06197d05839c\NetApp.exe
....after the ....\Apps\2.0\ - that changes.  i dont know how those folders are created...im guessing its got something to do with the registry....
0
 

Author Comment

by:fesit
ID: 19646827
point value is slowly going up.....
0
 
LVL 27

Expert Comment

by:VBRocks
ID: 19647029
Well, yes.  My point is, in ClickOnce deployment, there is no actual shortcut or executable that the user
ever uses.  All they do is launch the program from the install directory, then ClickOnce deployment
installs the program to a unique isolated directory and runs the program for the user.

Since you are using the Shell command to essentially launch the program, it doesn't really matter where
the application is actually installed to and run from by ClickOnce deployment.  Therefore, why not just
use the path to the installation program? (Install directory)

0
 

Author Comment

by:fesit
ID: 19647165
VBRocks,

That sounded like a really good idea.
You are talking about the Install Directory from the server side, correct?


I tried changing the path in the Shell command to "\\Server\SharedFolder\AppFolder\NetApp.application"
and i get "Invalid procedure call or agrument"
If i change it to .exe, i get File Not Found (because there is no .exe in there)
When using ClickOnce, does it just run the .application file on the server every time the user clicks on the icon in their Start Menu?  That re-installs the latest version of the app?

I also have not tested it, but I didnt know if there would be a user conflict if multiple employees launched the file from the server (that is the install directory) from the vb6 app.  I havent tested that, because I do not see an actual exe file in the Install Directory.
0
 
LVL 14

Expert Comment

by:wsh2
ID: 19647723
Nice article (though not definitive) on ClickOnce here:
http://www.15seconds.com/issue/041229.htm

In it the artice the author illustrates the final ClickOnce install directory by adding a button to the application with the following in it:
   MessageBox.Show(System.Reflection.Assembly.GetExecutingAssembly().Location);
This shows the directory that the program is installed in after installation. In a worse case scenario you may want to use reflection to build your own shortcut link.

One other interesting point I noted in the article is the need to select "Yes, this application is available offline or online" when you go to publish. I'm comfortable that you probably did that, however, it doesn;t hurt to mention it.
0
 
LVL 14

Expert Comment

by:wsh2
ID: 19647801
Further adding to my comment of above.. "worst case scenario"..

Upon initial startup of the ClickOnce application, using reflection, grab the program location and store it in the registry. When you want to Shell to the program from VB6, read the registry to get the proper executable location. This has the added benefit that if the ClickOnce application version is changed or re-installed in another location, the first execution of the program (which clickonce normally does) will update the registry so that no VB6 program changes will need to be made.
0
 
LVL 27

Accepted Solution

by:
VBRocks earned 204 total points
ID: 19649946
fesit:

Instead of using this:
    "\\Server\SharedFolder\AppFolder\NetApp.application",

Try using this:
    "\\Server\SharedFolder\AppFolder\setup.exe"


Providing there is a setup.exe there (there was for me).

0
 

Author Comment

by:fesit
ID: 19655165
VBRocks -

Almost.  It works if i use the setup.exe in the shell command, only problem is, out of the 5 times i tested pressing the button to call the shell object, it prompted me to Install the app 3 times.
It's not the end of the world if that happens, but it's kind of annoying to the user to keep having to install the application right after they just installed it the last time they clicked on the button.
so far, this is the closest thing though....

anybody have any thoughts??

thanks
jae
0
 
LVL 27

Expert Comment

by:VBRocks
ID: 19662421
Not sure why.  It doesn't do that for me.  It only installs the first time, then launches successfully every
time thereafter...

0
 
LVL 27

Expert Comment

by:VBRocks
ID: 19662436
Are you uninstalling it between launches?
0
 

Author Comment

by:fesit
ID: 19662987
nope. not uninstalling.
its random.  happens every once in a while.  not every time.  but id say maybe every 3 out of 10 times.
0
 
LVL 27

Expert Comment

by:VBRocks
ID: 19663401
Definitely annoying.  Sorry I don't have an answer for you on that one.
0
 

Author Comment

by:fesit
ID: 19719165
VBRocks - sorry it took me so long to reward points.
I got sidetracked on another project

Im still having that problem where every once in a while, it re-installs the application - but its the closest thing ive got for right now.

Thanks to everyone for their input.

Take care...
Jason
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month16 days, 15 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question