Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.NET 2003 Running .BAT Command 2

Status
Not open for further replies.

Skittle

ISP
Sep 10, 2002
1,528
US
I have a need to run a DOS BAT file from a .NET program.

What is the best way to do this?

What is the easiest way? I guess this would be an out of process solution?.






Dazed and confused
 
Yes, you will need to use an out of process solution. Oh, wait...I'm having a vision...I think...I think...you're next question is going to be how to launch and MONITOR the process :). I went through this a couple months ago and found a great article on DevX. here's the link...
 
Here is how I run winzip from within an app. It may be useful to you.


' Zip files with the option to delete all folders/files after the zipit batch file copletes.
'
Dim myProcess As Process = New Process
Try

myProcess.StartInfo.FileName = "cmd.exe"
myProcess.StartInfo.Arguments = "/K E: " & "&& CD E:\roi_temp" & "&& E:\roi_temp\zipit.bat"
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
myProcess.StartInfo.CreateNoWindow = True
myProcess.Start()
'myProcess.WaitForExit(100000)
myProcess.Close()
'MsgBox("File zip completed. You can now safely delete temp. folders", MsgBoxStyle.Information, "File Zip")
Catch ex As Exception
MsgBox("Error " & ex.ToString & " has occured", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Error Zipping Files")
End Try

The zipit.bat file contains the actual zip parameters.
 
Wounderful.

This has saved me a great deal of pain.
Thinking good thoughts about you macleod121!!




Dazed and confused
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top