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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dumping results of a DOS batch file to a text file (VB2008)

Status
Not open for further replies.

CarolCook

IS-IT--Management
Mar 7, 2003
158
0
0
US
I am calling a DOS batch file with the shell command. So far not much luck with using

objprocess.startinfo.arguments=" /c " & [batchfile string]

(It doesn't run). So for the moment pursuing this with the shell command. My issue is that when I execute the batchfile and append >c: foo.txt to dump output to a text file, it works fine from a command prompt or from a .bat file in the Windows XP environment. However, when I lift the *exact* syntax and append to my batch file strung in VB, while it does create the text file, it is blank.
 
dirx.bat is a simple batch file with only the "dir" dos command.


Try

Dim myProcess As System.Diagnostics.Process = _
New System.Diagnostics.Process()

myProcess.StartInfo.FileName = "c:\dirx.bat"
myProcess.StartInfo.Arguments = " > c:\dir.txt"
myProcess.StartInfo.WindowStyle = _
System.Diagnostics.ProcessWindowStyle.Normal
myProcess.Start()

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top