kumarbabu
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
Shell("C:\Windows\System32\calc.exe")
End Sub
Private Sub mgmt_suite_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
By setting
System.Environment.Current Directory = "C:\L1Applications\bin\" before the Process.Start line the software was able to be launched. The problem is now solved.
System.Environment.Current
You need to set the WorkingDirectory first:
Dim p As New Process
p.StartInfo.FileName = "C:\L1Applications\bin\L1- IMS"
p.StartInfo.WorkingDirecto ry = "C:\L1Applications\bin\"
p.StartInfo.WindowStyle = ProcessWindowStyle.Maximiz ed
p.Start()
Dim p As New Process
p.StartInfo.FileName = "C:\L1Applications\bin\L1-
p.StartInfo.WorkingDirecto
p.StartInfo.WindowStyle = ProcessWindowStyle.Maximiz
p.Start()
ASKER
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
Thanks,