Sh***********@gmail.com wrote:
I was trying to avoid using a batch file just due to some of my feilds
having sensitive information. That isn't the case anymore, but still
i'd like to pull this off just using a standard form and pulling up a
command prompt and doin what I need to get done.
My example showed how to call a batch file, but if you start cmd.exe as
a process, you can then use the redirected StandardInput to send
commands to the command processor:
Public Sub ExecuteDOSCommand()
Using m_Process As New Process()
With m_Process.StartInfo
.FileName = "cmd.exe"
.UseShellExecute = False
.CreateNoWindow = True
.RedirectStandardInput = True
End With
Dim start As DateTime = DateTime.Now
m_Process.Start()
m_Process.StandardInput.WriteLine("copy /Y
\\server\folder\ut* c:\data")
m_Process.Close()
End Using
End Sub
Now im trying to use this statment to copy a couple files from one
directory to another through dos with VB.NET.
copy \\(server name goes here)\(file name goes here)\ ut* c:\data
the ut* is asking for all files with the prefix ut (if you didn't know
that)
The copy command would be copy \\servername\ut* c:\data
You have a space just before the ut*.
But why on earth would you want to use the command prompt to copy the
files when you can use the classes in the System.IO namespace?
Imports System.IO
Public Sub CopyFiles()
Dim destination As String = "c:\data"
Dim filesToCopy() As String =
Directory.GetFiles("\\servername\folder", "ut*")
For Each filename As String In filesToCopy
File.Copy(filename, Path.Combine(destination,
Path.GetFileName(filename)))
Next
End Sub
You'll probably want to add some exception handling to handle any
errors.
when I send this command to the command prompt using the following
statment
SendKeys.Send(strPath & "{enter}")
where strPath = "copy \\(servername goes here)\(file name goes
here)\ut" & ChrW(42) & " c:\data"
the only thing that shows up in the command prompt is * c:\data
I cannot answer this as I do not use SendKeys.