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
Avatar of buzzle74

Blurred text
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of kumarbabu
Flag of United States of America image


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?

Avatar of kumarbabu
Flag of United States of America image


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.
Avatar of 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
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews


IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo