Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

CALLING AN APPLICATION FROM WITHIN AN APPLICATION

Posted on 2012-09-06
9
Medium Priority
?
340 Views
Last Modified: 2012-09-08
Hi All,

I try to open an app from within an app.

Module mdlMain

    Public Sub Main(ByVal pArgs() As String)

        If pArgs.Length > 0 Then
            For intI As Int32 = 0 To pArgs.Length - 1
                pArgs(intI) = pArgs(intI).ToUpper

                Select Case intI
                    Case 0
                        ERV_Global.strLoginUserID = pArgs(intI)
                    Case 1
                        ERV_Global.strLoginUserName = pArgs(intI)
                End Select


            Next

        End If

        MsgBox(pArgs.Length) -----> return 0

        Application.Run(frmMain)
    End Sub

Caller :

  Dim p As New Process()

                p.EnableRaisingEvents = False
                p.StartInfo.UseShellExecute = False
                p.StartInfo.CreateNoWindow = True
                p.StartInfo.FileName = strApplicationName
                p.StartInfo.Arguments = ERV_Global.strLoginUserID & " " & ERV_Global.strLoginUserName.Trim
                p.Start()

What's wrong ?

Thank you.
0
Comment
Question by:emi_sastra
  • 5
  • 4
9 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 38372423
Are you sure you're actually passing valid arguments?

                p.StartInfo.Arguments = ERV_Global.strLoginUserID & " " & ERV_Global.strLoginUserName.Trim
               MessageBox.Show(p.StartInfo.Arguments, "Arguments")
                p.Start()
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 38374417
Hi  Idle_Mind,

- Are you sure you're actually passing valid arguments?
Yes, It is.

I have seen from a link said that below code make some problem for passing arguments,
I forget where is it and how to overcome this.

     p.StartInfo.UseShellExecute = False
                p.StartInfo.CreateNoWindow = True

First, I use this because I want to avoid cmd window still active after calling the batch file.

Thank you.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 38376438
Not sure about that.

What are the values that ultimately end up in these?

    p.StartInfo.FileName = strApplicationName
    p.StartInfo.Arguments = ERV_Global.strLoginUserID & " " & ERV_Global.strLoginUserName.Trim
0
Industry Leaders: 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!

 
LVL 1

Author Comment

by:emi_sastra
ID: 38376691
strApplicationName + "ERV_INVENTORY"
ERV_Global.strLoginUserID = "EMI"
ERV_Global.strLoginUserName.Trim = "ABCD123"

Thank you.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 38376871
I'm not sure what's going on.  What happens if you output this to the Immediate window, then copy and paste it from a command-line prompt?

    Dim cmd As String =  p.StartInfo.FileName & " " & p.StartInfo.Arguments
    Debug.Print(cmd)
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 38376920
Hi Idle_Mind,

I am sorry,  my mistakes.

The  p.StartInfo.FileName  = batch file name., should be app name without ".exe".

Why I call the bacth file because it runs below code :

@ECHO OFF
CD D:\EMI NEW\COMPILED\MKE\
COPY D:\SERVER\ERV\ERV_INVENTORY.EXE>NULL
ERV_INVENTORY.EXE

What I suppose to do if without it ?

Thank you.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 38376969
"should be app name without ".exe""

So you need?

    p.StartInfo.FileName = System.IO.Path.GetFileNameWithoutExtension(strApplicationName)
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 38376996
So you need?

    p.StartInfo.FileName = System.IO.Path.GetFileNameWithoutExtension(strApplicationName)

Yes, it works now. But I still need to copy exe file from server to caller computer that is done by the batch file.

Thank you.
0
 
LVL 1

Author Closing Comment

by:emi_sastra
ID: 38380412
Hi Idle_Mind,

Thank you very much for your help.
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…

580 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