Avatar of kumarbabu
kumarbabuFlag for United States of America asked on

use of shell command in Visual Basic Express 2008

I am writing a program in Visual Basic Express 2008. I need to call an executable using a button click. I have two buttons in the program. . Somehow the executable does not seem to run. If I run the executable from the command line it always works and throws up a menu in the screen. When called from my visual basic program nothing shows up the screen. What am I doing wrong? The second button which calls calc.exe always works.The code is shown below. If I replace the content of the shell for button1_click with the pathname for calc.exe, then that runs.
Public Class mgmt_suite
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MgmtSuite.Click
        Shell("C:\L1Applications\bin\L1-IMS", AppWinStyle.MaximizedFocus)
    End Sub
    Private Sub Global_traveler_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Global_Traveler.Click
    End Sub
    Private Sub mgmt_suite_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub
End Class

Open in new window

SoftwareMicrosoft DevelopmentVisual Basic.NET

Avatar of undefined
Last Comment
Mike Tomlinson

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Hi buzzle74,

Thanks for your solution. It was very helpful. However, for some reason the solution proposed works when I call other executables. However, it does not seem to work for the particular executable "L1Applications\bin\L1-IMS"; This application runs by itself without any problem but I can't seem to use VB to call it. Any ideas on why this particular application is unresponsive to a call from VB?


By setting
System.Environment.CurrentDirectory = "C:\L1Applications\bin\" before the Process.Start line the software was able to be launched. The problem is now solved.
Mike Tomlinson

You need to set the WorkingDirectory first:

        Dim p As New Process
        p.StartInfo.FileName = "C:\L1Applications\bin\L1-IMS"
        p.StartInfo.WorkingDirectory = "C:\L1Applications\bin\"
        p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck