Solved

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

Posted on 2010-11-27
4
1,179 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 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