Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub CreateBackup()
- Dim mysqldumpPath As String = "C:\wamp\bin\mysql\mysql5.6.17\bin\mysqldump.exe"
- Dim host As String = "localhost"
- Dim user As String = "root"
- Dim pswd As String = ""
- Dim dbnm As String = "switchcity"
- Dim cmd As String = String.Format("-h{0} -u{1} -p{2} {3}", host, user, pswd, dbnm)
- Dim filePath As String = "F:\backup\switchDB.sql"
- OutputStream = New System.IO.StreamWriter(filePath, False, System.Text.Encoding.UTF8)
- Dim startInfo As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo()
- startInfo.FileName = mysqldumpPath
- startInfo.Arguments = cmd
- startInfo.RedirectStandardError = True
- startInfo.RedirectStandardInput = False
- startInfo.RedirectStandardOutput = True
- startInfo.UseShellExecute = False
- startInfo.CreateNoWindow = True
- startInfo.ErrorDialog = False
- Dim proc As System.Diagnostics.Process = New System.Diagnostics.Process()
- proc.StartInfo = startInfo
- AddHandler proc.OutputDataReceived, AddressOf OnDataReceived1
- proc.Start()
- proc.BeginOutputReadLine()
- proc.WaitForExit()
- OutputStream.Flush()
- OutputStream.Close()
- proc.Close()
- End Sub
Add Comment
Please, Sign In to add comment