Cari Blog Ini

12 Juli 2013

How To Schedulling Automatic Backup Code Application

Want to :

* Backup code application automatically using schedulling 

* Compress the backup code application





Step :

1. Example code that want to backup.


2. First, must have software "Zip.exe"

3. Create a new file name "BackupApp_Code.vbs", and fill the below code :


'-------------------------------------------------------------------------------
'----- code start
'-------------------------------------------------------------------------------
OPTION EXPLICIT 
dim ws, TimeStampInfo, FileNameInfo, StrInfo

TimeStampInfo = 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") 

FileNameInfo ="D:\AutoBackupApp\HRD_Code_" & TimeStampInfo & ".zip" 
'----FileNameInfo ="\\xxx.xxx.xxx.44\AutoBackupApp\HRD_Code_" & TimeStampInfo & ".zip" 


StrInfo ="""cmd.exe"" /c D:\AutoBackupApp\zip.exe -r " & """" & FileNameInfo & """ " & """D:\HRD_Code\*.*"" "
'----StrInfo ="""cmd.exe"" /c \\xxx.xxx.xxx.41\AutoBackupApp\zip.exe -r " & """" & FileNameInfo & """ " & """D:\HRD_Code\*.*"" "

ws.run StrInfo

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





4. Try to run or double-click file name "BackupApp_Code.vbs"






Here is for Create An Schedulling In Task Schedule

5. Go to "Control Panel > Scheduled Task"



6. Create a name, example "AutoBackupApp_Code"
In Tab "Task" 
A. Run = fill with the path of script.
B. Start In = fill the folder location of script. 
C. Run as = set with an your login.




7. In Tab "Schedule", set the time for run  Scheduled Task. 



8. Click Apply and OK. 



9. Try to run the Task Scheduled.