Board logo

标题: [已解决]10元求合并下列代码 [打印本页]

作者: brothersonline    时间: 2017-7-18 22:46     标题: [已解决]10元求合并下列代码

请高手将此批处理及SQL、VBS文件合并成一个VBS文件(有偿),在windows 2008 server (64位)下执行
目的:在win2008 server下静默执行此VBS文件,将sql数据库备份
SQL:
  1. DECLARE @name varchar(45)
  2. DECLARE @datetime char(17)
  3. DECLARE @path varchar(255)
  4. DECLARE @bakfile varchar(290)
  5. set @name='GXSV4'
  6. set @datetime=CONVERT(char(11),getdate(),120) + REPLACE(CONVERT(char(8),getdate(),108),':','')
  7. set @path='D:\SQLBACKUP'
  8. set @bakfile=@path+'/'+@name+'_'+@datetime+'.BAK'
  9. backup database @name to disk=@bakfile with name=@name
  10. go
复制代码
批处理:
  1. @echo off
  2. set path=%path%;C:\Program Files\Microsoft SQL Server\100\Tools\Binn
  3. set dates=%date% %time%
  4. echo %dates% >> D:\SQLBACKUP\logs.txt
  5. echo Sql_Back_Start >> D:\SQLBACKUP\logs.txt
  6. echo . >> D:\SQLBACKUP\logs.txt
  7. SQLCMD.exe  -S 127.0.0.1 -U sa -P Abc123 -i mybackup.sql
  8. set dates=%date% %time%
  9. echo %dates% >> D:\SQLBACKUP\logs.txt
  10. echo Sql_Back_Finish >> D:\SQLBACKUP\logs.txt
  11. echo . >> D:\SQLBACKUP\logs.txt
  12. echo . >> D:\SQLBACKUP\logs.txt
  13. ::pause
复制代码
VBS文件:
  1. Dim WSHShell
  2. Set WSHShell = WScript.CreateObject("WScript.Shell")
  3. WSHShell.run "cmd /c AutoBackup.BAT",vbhide
  4. Set WSHShell = Nothing
  5. WScript.Quit(0)
复制代码





欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2