running dos command in vb.net

cjaymcmeans

Well-known member
Joined
Jan 12, 2005
Messages
85
Programming Experience
3-5
any one out there who knows how to run a dos command using vb.net.. need help fast... kinda stuck in tryign to back up a database using a dos script... please help.. tnx..
 
Dos Command

You have to use the System.Diagnostics.Process class. The following code issues a dir command and retrieves all the output generated by the command prompt in a string variable. You can write its contents to a file if you want: ProcessStartInfo si = new ProcessStartInfo("cmd.exe");// Redirect both streams so we can write/read them.si.RedirectStandardInput = true;si.RedirectStandardOutput = true;si.UseShellExecute = false;// Start the procses.Process p = Process.Start(si);// Issue the dir command.p.StandardInput.WriteLine(@"dir c:");// Exit the application.p.StandardInput.WriteLine(@"exit");// Read all the output generated from it.string output = p.StandardOutput.ReadToEnd();
 
VB.NET:
Process.Start(strFilename)
overloads exist
 
Back
Top