Solved

use vb.net to execute shells commands

Posted on 2010-08-23
2
809 Views
Last Modified: 2013-11-27
How do I use vb,net to excute shells/DOS commands...

How would I use vb,net to open a shell command at a specific location on a directory file...then excute commands and pull data into varaibles...
0
Comment
Question by:GlobaLevel
2 Comments
 
LVL 30

Accepted Solution

by:
Brad Howe earned 250 total points
ID: 33507530
Hi,

For VB.NET and excuting command line tasks, you can use the SHELL command.

SHELL  Syntax :
shell(path_Name[,style][,wait][,timeout])
path_name = executable file with the full path of the application which it want to call
Style = a model of application window which it want to call (ex minimize,normal etc).
Wait = a boolean value that prescriptive whether shell function has to wait vb.net finish before working. false is the default value.
TimeOut = a wait time that it needful by shell function to start working if Wait in true value.

ex.
        Shell("cmd /C "C:\applicationfolder\app.exe, 0, True)

When executing commandline, you are only going to get a return code 1,0 or custom.

To get those details.

1. Can you not get this data directly through VB.NET by parsing?
2. Can you not execute this commandline task and pipe the details to a temp.txt for processing after completion?

Just some ideas,
Hades666
0
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 250 total points
ID: 33507671
For VB.Net you use the Process() Class:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx

You can redirect the StandardOutput():
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx

If you give more details then we can give specific examples...
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

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