Cari Blog Ini

21 Desember 2011

VB Script for Backup Folder

Save the code below, as "Backup_Code_Absensi_EachDay.vbs"
Then double-click the file, to get the results in file. zip

'--------------------------------------------------------------------------------
'-----code start
'--------------------------------------------------------------------------------
OPTION EXPLICIT
dim ws, MyTimeStamp, MyFileName, MyStr



MyTimeStamp = cstr(year(now))  & _
    right(cstr(100+month(now)),2)  & _
    right(cstr(100+day(now)),2) & "_" & _
    right(cstr(100+hour(now)),2) & _
    right(cstr(100+minute(now)),2)

Set ws = WScript.CreateObject("WScript.Shell")

MyFileName ="E:\ProgramTestingAbsensi\BackupCodeAbsensi\CodeAbsensi_" & MyTimeStamp  & ".zip"

MyStr="""cmd.exe"" /c E:\ProgramTestingAbsensi\BackupCodeAbsensi\zip.exe -r " & _
    """" & MyFileName & """ " & _
    """E:\ProgramTestingAbsensi\CodeAbsensi\*.*"" "

ws.run MyStr

'--------------------------------------------------------------------------------
'-----code end
'--------------------------------------------------------------------------------