Hi
I want to run the the dos command like dir, vol, copy in vb.net
how can i call it in vb.net
thanks
asm
Printable View
Hi
I want to run the the dos command like dir, vol, copy in vb.net
how can i call it in vb.net
thanks
asm
Start a process of the "cmd.exe" and pass the DOS commands as arguments. To get the results of a Dir or something you can pass the output to character along with a filename/path to write the results to.
VB Code:
System.Diagnostics.Start("C:\Windows\System32\CMD.exe", "Dir C: > C:\Dir.txt")
error message "Start is not a member of Diagnostics"
Sorry, freehand typed it. It should be
system.Diagnostics.Process.Start or so.
it will open the cmd window but unable to print dir in dir.txt
and also window will not close
Try using the /C switch for the cmd.exe to tell it to close after processing....
VB Code:
System.Diagnostics.Process.Start("C:\Windows\System32\CMD.exe /C", "Dir C: > C:\Dir.txt")
Still error message :
"An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in system.dll
Additional information: The system cannot find the file specified"
my code:
mports System
Imports System.Data
Imports System.Windows
Imports System.Diagnostics
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
System.Diagnostics.Process.Start("C:\Windows\System32\CMD.exe /C", "Dir C: > C:\Dir.txt")
End Sub
End Class
VB Code:
System.Diagnostics.Process.Start("C:\Windows\System32\CMD.exe", " /C Dir C: > C:\Dir.txt")
Thanks ... It working fine
Np, ;) Sorry it took so many attempts. I have to go by memory as I dont have 2003 installed yet. :(