Solved

Visual Basic 2010 Shell command to change foler and run command in the folder

Posted on 2010-11-27
4
1,177 Views
Last Modified: 2013-11-26
Hi
I am writting a small program in Visual Basic studio 2010, I would like to shell to a command prompt change the working directory then run a command still within the working directory, can anyone tell me how this can be achieved
0
Comment
Question by:sykotex
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34222050
Are you talking about a Console application, that can interact with the Console?  Or, are you talking about using System.Diagnostics.Process?
0
 
LVL 1

Author Comment

by:sykotex
ID: 34222069
I'm a begginer so I may not be to clear. I have a program which runs from a command line. I am writting a windows form front end that will ulimatley run this program with its switches at the end. The switches for the command line program use file paths which don't appear to work if a full path is entered
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 34222625
If you have a Windows Forms application, and you need to start an external process, you can use the System.Diagnostics.Process class, like in this example:

Process Class (System.Diagnostics)

Dim myProcess As New Process()

            Try                ' Get the path that stores user documents.

                myProcess.StartInfo.UseShellExecute = False
                ' You can start any process, HelloWorld is a do-nothing example.
                myProcess.StartInfo.FileName = "C:\\HelloWorld.exe"
                myProcess.StartInfo.CreateNoWindow = True
                myProcess.Start()
                ' This code assumes the process you are starting will terminate itself. 
                ' Given that is is started without a window so you cannot terminate it 
                ' on the desktop, it must terminate itself or you can do it programmatically
                ' from this application using the Kill method.

Open in new window

0
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 34222914
please go through the following link, it clearly tells how to add console in a windows form:-

http://stackoverflow.com/questions/252323/how-do-i-add-a-console-like-element-to-a-c-winforms-program
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…

832 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