Windows Develop Bookmark and Share   
 index > Windows Forms General > Shelling out to an executable
 

Shelling out to an executable

I need to shell out from a VB6 executable to an existing .Net executable which can accept two optional parameters. When testing and forcing the two optional parameters by hard-coding the optional values in the .Net executable, it works fine. When I try and shell out from the VB6 program, the parameters only show up as empty strings (I have a messagebox coming up in the .Net executable that tells me the incoming input parameters).

Here is my .Net code:

Public Class frmSignon
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New(Optional ByVal strMenuItem As String = "", Optional ByVal strDataSource As String = "")
        MyBase.New()
        'This call is required by the Windows Form Designer.
        InitializeComponent()
        'Add any initialization after the InitializeComponent() call
    End Sub
.
.
.
Private strAutomatedMenuItem As String = strMenuItem
Private strIncomingCVDataSource As String = strDataSource
.
.
.

    Private Sub frmSignon_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
.
.
.
MessageBox.Show(strAutomatedMenuItem, "frmsignon - menu item")
MessageBox.Show(strIncomingCVDataSource, "frmsignon - data source")
.
.
.
    End Sub

The following is the script that I'm executing from the "Run" command to test with:
C:\Development\FiberNetReporting\bin\FiberNetReporting.exe A CVCN

The "A" above is the first parameter and the "CVCN" value above is the second parameter.
When I hard code these values into the following:

Public Sub New(Optional ByVal strMenuItem As String = "A", Optional ByVal strDataSource As String = "CVCN"), it works fine.

However, I need to leave them as a default empty string because they should not be hard-coded.

Does anybody know how I can successfully pass in parameters from one executable to another? 
MigrationUser 1  Monday, February 17, 2003 2:26 PM
If you were doing a Console App something like that would work, but I believe since you're creating a WindowsForms App you'll need to use System.Environment.GetCommandLineArgs
MigrationUser 1  Monday, February 17, 2003 2:30 PM
i need to do this OUTSIDE of .Net, thereby needing the Shell command..........

Still havn't figured out how to do it................
MigrationUser 1  Monday, February 17, 2003 4:57 PM
In VB6 when I have shelled out to exes (though never a .net exe), I have just built the command using concatenation into a string and then shell uses that string for execution.

For example, this FoxPro app, billoutp.exe, needs a date as a parameter and then a "-t" param.
 
sShell = sBillingFolder & "\billoutp.exe " & Chr(34) & _
 CStr(Format(DateClicked, "mm/dd/yyyy")) & Chr(34) & " -t"

Shell sShell, vbMinimizedNoFocus

HTH

julie
MigrationUser 1  Monday, February 17, 2003 5:18 PM
I was using my frmSignOn as my startup form trying to pass in the parms in the Sub New event.

I implemented a Sub Main with the following code which worked fine.....

Module Main

    Private mForm As frmSignon

    Public Sub Main(ByVal args() As String)

        If args.Length = 0 Then
            mForm = New frmSignon()
        Else
            mForm = New frmSignon(args(0), args(1))
        End If

        Application.Run(mForm)

    End Sub

End Module

Bill.........
MigrationUser 1  Monday, February 17, 2003 5:41 PM
Bill-

Was the problem that you didn't know how to make the call in VB6 with variable parameters, or that you didn't know how to set up the .NET application to accept parameters?

From looking at this code, I think it was the 2nd, right?

So you started out asking for help, but ended up teaching us all a good trick!

Thanks!!

julie
MigrationUser 1  Monday, February 17, 2003 7:03 PM

You can use google to search for other answers

Custom Search

More Threads

• Datagridview, bindingsource, thread problem
• I need formatting tool bar for rich text box
• BUG: Unhandled exception in system.windows.forms.dll
• Change MessageBox Buttons Text
• textbox cursor
• Creating UserControl on a ThreadPool thread...why does this work?
• I.E. Error
• GUI Appearance Qualities
• Create form label on the fly
• user access control