using code to open another .exe file

trying to make a console .exe file be opened using a vb.net form

Page 1 of 1

6 Replies - 7907 Views - Last Post: 02 February 2013 - 06:45 AM Rate Topic: -----

#1 unlimited24  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 45
  • Joined: 28-August 08

using code to open another .exe file

Posted 09 March 2009 - 06:54 AM

hi. I would like to find out how would it be possible to make a executable be lunched at the click of a button from a vb.net form.

what I have so far is a form with a few button on.

for example:

button 1 is called 'RegEdit'
button 2 is called 'system information'

I have compile a command line application with VB.net containing this simple commands:
Module Module1

	Sub Main()
		Dim myprocess As System.Diagnostics.Process = New System.Diagnostics.Process()
		myprocess.StartInfo.FileName = "regedit.exe"
		myprocess.Start()

	End Sub
End Module



this complied will lunch regedit as instructed but what I would like to do is to put the console app .exe file into a root file of the application.

I would like to be able to have, once this project is completed, a main folder with the name of the app and then a sub dir called 'resources'. the 'resources' folder would have the various command line .exe with instructions to open various system programs.

how can I code a button to luch these .exe file within the 'resource' folder ?

thanks and hope it makes sence :)

Is This A Good Question/Topic? 0
  • +

Replies To: using code to open another .exe file

#2 Wrecks  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 71
  • Joined: 24-February 09

Re: using code to open another .exe file

Posted 09 March 2009 - 07:43 AM

Try replacing:
Dim myprocess As System.Diagnostics.Process = New System.Diagnostics.Process()
myprocess.StartInfo.FileName = "regedit.exe"
myprocess.Start()


With:
Shell("regedit")
Was This Post Helpful? 0
  • +
  • -

#3 unlimited24  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 45
  • Joined: 28-August 08

Re: using code to open another .exe file

Posted 09 March 2009 - 07:48 AM

when I use Shell ("regedit.exe") it comes with

Quote

A first chance exception of type 'System.IO.FileNotFoundException' occurred in Microsoft.VisualBasic.dll


thanks for the try anyway.

but I tihnk my first post was not fully understood :(

This post has been edited by unlimited24: 09 March 2009 - 07:49 AM

Was This Post Helpful? 0
  • +
  • -

#4 iamlarasmith  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 30-January 13

Re: using code to open another .exe file

Posted 31 January 2013 - 01:43 AM

Seeing your question, i tried to create an app out of it. :gunsmilie:

I created a form with a single button on it.
I also inserted an EXE file to the directory of this application (In my case its - D:\ShellandPath\bin\Debug), the name of the EXE file is: eqnedit.exe to be trigerred by the button.

Is the one that you're looking for?

Here's the Screenshot:
Posted Image

Here's the code for copy paste:

Imports System.IO

Public Class frmOpenExe
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedToolWindow
    End Sub

    Dim dirPath As String = Directory.GetCurrentDirectory()

    Private Sub cmdOpenExe_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOpenExe.Click
        Shell(dirPath & "\eqnedit.exe", AppWinStyle.NormalFocus)
    End Sub
End Class



I hope this helps... :detective:
Was This Post Helpful? 0
  • +
  • -

#5 IronRazer  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 294
  • View blog
  • Posts: 924
  • Joined: 01-February 13

Re: using code to open another .exe file

Posted 01 February 2013 - 09:47 PM

Hi iamlarasmith,
You can use this to get your apps directory path no matter where the folder that it is in is located. Even if you move the main folder, it gets the new path. Then add your resource folder and program name you want to execute like this :

        Dim dirPath As String = My.Application.Info.DirectoryPath & "\resources\eqnedit.exe"


Was This Post Helpful? 0
  • +
  • -

#6 iamlarasmith  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 30-January 13

Re: using code to open another .exe file

Posted 02 February 2013 - 12:09 AM

View PostIronRazer, on 01 February 2013 - 09:47 PM, said:

Hi iamlarasmith,
You can use this to get your apps directory path no matter where the folder that it is in is located. Even if you move the main folder, it gets the new path. Then add your resource folder and program name you want to execute like this :

        Dim dirPath As String = My.Application.Info.DirectoryPath & "\resources\eqnedit.exe"



Thanks for the additional info... This task is much simpler in VB6:

shell(App.path & "\resources\eqnedit.exe")


:D
Was This Post Helpful? 0
  • +
  • -

#7 IronRazer  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 294
  • View blog
  • Posts: 924
  • Joined: 01-February 13

Re: using code to open another .exe file

Posted 02 February 2013 - 06:45 AM

Hey iamlarasmith,
No problem. I am glad it helped. :bananaman:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1