本帖最后由 Demon 于 2012-2-7 09:33 编辑
- @echo off
- >"%tmp%\MyDel.vbs" echo dt=date()-1
- >>"%tmp%\MyDel.vbs" echo s=right(year(dt),4) ^& right("0" ^& month(dt),2) ^& right("0" ^& day(dt),2)
- >>"%tmp%\MyDel.vbs" echo wscript.echo s
- for /f %%a in ('cscript /nologo "%tmp%\MyDel.vbs"') do set yesterday=%%a
- echo %yesterday%
- >CD C:\Program Files\MySQL\MySQL Server 5.1\bin\
- >>mysqldump -u root -p test>"E:\software install\testDatabaseBackup\cvtbarcode%yesterday%test.sql"
- pause
复制代码 提示有错误,怎么修改?如果系统提示密码,怎么在批处理程序里添加?
lazygc520 发表于 2012-2-6 12:11 
不伦不类
'Author: Demon
'Website: http://demon.tw
'Date: 2012/2/7
Option Explicit
Const user = "root"
Const pass = "123456"
Const data = "test"
Const dump = "C:\Program Files\MySQL\MySQL Server 5.1\bin\"
Const dest = "E:\software install\testDatabaseBackup\"
Dim yesterday, t
t = Date - 1
yesterday = Year(t) & Right("0" & Month(t), 2) & Right("0" & Day(t), 2)
yesterday = dest & "cvtbarcode" & yesterday & ".sql"
Dim WshShell, Cmd
Set WshShell = CreateObject("wscript.Shell")
WshShell.CurrentDirectory = dump
Cmd = "mysqldump -u " & user & " -p" & pass & " -r " & yesterday & " " & data
WshShell.Run Cmd, 0, True
MsgBox "Backup complete", vbInformation
|