D:\wamp\bin\mysql\mysql5.1.36\bin\mysqldump.exe --opt -R -u root -pvaodesql_2011 k801>"D:/wamp/vaode_mysql_backup/k801_mysql_backup当前年月日分秒.sql;
需求如下:0,6,12,18,定点备份数据库,执行dos命令!
1 回答
Cats萌萌
TA贡献1805条经验 获得超9个赞
//摘录:《程序员秘书》--源代码--进程--后台执行DOS命令 private void button1_Click(object sender, EventArgs e) { Process myProcess = new Process(); myProcess.StartInfo.FileName = "cmd.exe ";//DOS控制平台 myProcess.StartInfo.UseShellExecute = false; myProcess.StartInfo.CreateNoWindow = true; myProcess.StartInfo.RedirectStandardInput = true; myProcess.StartInfo.RedirectStandardOutput = true; myProcess.StartInfo.RedirectStandardError = true; myProcess.Start(); StreamWriter sIn = myProcess.StandardInput;//标准输入流 sIn.AutoFlush = true; StreamReader sOut = myProcess.StandardOutput;//标准输入流 StreamReader sErr = myProcess.StandardError;//标准错误流 sIn.Write( "ver " + System.Environment.NewLine);//DOS控制平台上的命令 sIn.Write( "dir " + System.Environment.NewLine);//DOS控制平台上的命令 sIn.Write( "exit " + System.Environment.NewLine); string s = sOut.ReadToEnd();//读取执行DOS命令后输出信息 string er = sErr.ReadToEnd();//读取执行DOS命令后错误信息 richTextBox1.AppendText(s); richTextBox1.AppendText(er); if (myProcess.HasExited == false) { myProcess.Kill(); } sIn.Close(); sOut.Close(); sErr.Close(); myProcess.Close(); }
- 1 回答
- 0 关注
- 351 浏览
添加回答
举报
0/150
提交
取消