Execute a .exe file remotely (in another directory) in a VB2010 menu

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Im making a VB2010 program that is a simple menu to go on the root of an optical disc to install and run the software thats on the disc. The actual software is installed using InstallShield, the VB menu is just a way to provide a nice graphical interface
when you insert the disc. Ive made a few of these programs before, but all in VB6 - this is my first attempt to make a VB2010 program, so Im basically going through an old VB6 project file and rewriting it in VB2010, which is easy in parts, not so easy in
others.
The program simply consists of a background and two buttons - the first button Install simply runs the InstallShield setup.exe file thats in the same folder as the VB application. The other button Play is disabled by default but enabled if the VB program
can detect that the software is installed, which it does by checking the registry for the install directory of the software, and then the install directory for the presence of the softwares executable file.
So far so good - all of that and its working fine. The problem I have is when I run the executable file in the install directory. The software is not running properly because its executable is being run from another directory. I need to get VB2010 to run
the software from the softwares installed directory, rather than from the root of the disc that it is actually on.
In my VB6 program, the code looks like this -
<pre class="prettyprint lang-vb" style=" ShellExecute Me.hwnd, vbNullString, InstallDir & "Software.exe", vbNullString, InstallDir, 1[/code]
Where InstallDir is the install directory, acquired from the registry. The second instance of InstallDir in that line tells VB6 to run Software.exe from that folder.
In VB2010 Im running the .exe using -
<pre class="prettyprint lang-vb" style=" Process.Start(InstallDir & "Software.exe")[/code]
But with that, the software isnt running properly - its throwing up an error message about it not being run from the correct directory (which it isnt). If I build the project and put the .exe file in the install directory, it works fine, but obviously
thats not where I want it to be.
I have tried this -
<pre class="prettyprint lang-vb" style=" ChDir(InstallDir)
Process.Start("Software.exe")[/code]
And that seems to work. However, Im not sure about using ChDir - is that the best way of doing this? Isnt there a way of doing this in one line, i.e. by adding a parameter to Process.Start after "Software.exe"?
Any help is much appreciated - as I said, Im new to VB2010 so Id like to avoid picking up any bad habits early on!

<br/>

View the full article
 
Back
Top