comnetlimited
Technical User
Hello people.
I have a VBScript that Backs up files. I want this script to run manually and also to run when schedule. The problem is I don't how will I make it so that the task response to the message box and confirmation box. I need your help. See my Code below.
Option Explicit
Sub BackupStatements()
Dim FSO, oDiv, oShp, oFile,oSubFolder, oBackUp,f1
Dim str, ctr, temp, cnt, pos, test,strSF, strDiv,sFN, Dcnt, Tcnt, TDcnt, Sum
Dim resp
resp = msgbox ("This script will Backup All the Statements" ,65, "Information")
If resp = 1 then
Tcnt = 0
TDcnt = 0
Set FSO = CreateObject("Scripting.FileSystemObject")
Set f1 = FSO.CreateTextFile("C:\Program Files\Adobe\Central\Server5\data\BackupStatements.dat", True)
f1.WriteLine("^Job STMTBACKUP -ZMIS03P")
f1.WriteLine("csd_helpdesk@steamships.com.pg;mnarewec@steamships.com.pg")
f1.WriteLine("JetForm Statements Backup Summary " & Now() )
Set oBackUp = FSO.GetFolder("E:\Jfbackup")
For each oSubFolder In oBackup.SubFolders
cnt = 0
Dcnt = 0
strSF = oSubFolder.Name
If Lcase(Left(oSubfolder.Name,4)) = "stmt" Then
Set oDiv = FSO.GetFolder(oBackUp & "\" & strSF)
strDiv = Ucase(Right(oSubfolder.Name,3))
f1.WriteLine(Ucase(Right(oSubfolder.Name,3))) & " Statement Files......."
For Each oFile In oDiv.Files
str = oFile.Name
pos = InStr(str, "Date") + 5
temp = mid(str,pos,8)
sFN= Year(temp) & Right("0"& Month(temp),2) & Right("0" & Day(temp),2)
If FSO.FolderExists(oDiv & "\" & sFN) = False Then
FSO.CreateFolder(oDiv & "\" & sFN)
End if
If FSO.FileExists(oDiv & "\" & sFN & "\" & str) = False Then
FSO.MoveFile oDiv & "\" & str, oDiv & "\" & sFN & "\"
cnt = cnt +1
Else
FSO.DeleteFile oDiv & "\" & str, True
Dcnt = Dcnt +1
End If
Next
Tcnt = Tcnt + cnt
TDCnt = TDCnt + Dcnt
f1.Writeline(cnt & " File(s) Backed up.")
f1.Writeline(Dcnt & " Duplicate File(s) deleted.")
f1.WriteLine("----------------------------------------------------")
Set oFile = Nothing
Set oDiv= Nothing
End If
Next
f1.Writeline(Tcnt & " Total File(s) Backed up.")
f1.Writeline(TDcnt & " Total Duplicate File(s) deleted.")
f1.Close
Sum = TDcnt + Tcnt
wscript.echo Sum & " Statement Files Processed. Summary of which is being Emailed to CSD Help Desk."
End If
End Sub
Call BackupStatements
I have a VBScript that Backs up files. I want this script to run manually and also to run when schedule. The problem is I don't how will I make it so that the task response to the message box and confirmation box. I need your help. See my Code below.
Option Explicit
Sub BackupStatements()
Dim FSO, oDiv, oShp, oFile,oSubFolder, oBackUp,f1
Dim str, ctr, temp, cnt, pos, test,strSF, strDiv,sFN, Dcnt, Tcnt, TDcnt, Sum
Dim resp
resp = msgbox ("This script will Backup All the Statements" ,65, "Information")
If resp = 1 then
Tcnt = 0
TDcnt = 0
Set FSO = CreateObject("Scripting.FileSystemObject")
Set f1 = FSO.CreateTextFile("C:\Program Files\Adobe\Central\Server5\data\BackupStatements.dat", True)
f1.WriteLine("^Job STMTBACKUP -ZMIS03P")
f1.WriteLine("csd_helpdesk@steamships.com.pg;mnarewec@steamships.com.pg")
f1.WriteLine("JetForm Statements Backup Summary " & Now() )
Set oBackUp = FSO.GetFolder("E:\Jfbackup")
For each oSubFolder In oBackup.SubFolders
cnt = 0
Dcnt = 0
strSF = oSubFolder.Name
If Lcase(Left(oSubfolder.Name,4)) = "stmt" Then
Set oDiv = FSO.GetFolder(oBackUp & "\" & strSF)
strDiv = Ucase(Right(oSubfolder.Name,3))
f1.WriteLine(Ucase(Right(oSubfolder.Name,3))) & " Statement Files......."
For Each oFile In oDiv.Files
str = oFile.Name
pos = InStr(str, "Date") + 5
temp = mid(str,pos,8)
sFN= Year(temp) & Right("0"& Month(temp),2) & Right("0" & Day(temp),2)
If FSO.FolderExists(oDiv & "\" & sFN) = False Then
FSO.CreateFolder(oDiv & "\" & sFN)
End if
If FSO.FileExists(oDiv & "\" & sFN & "\" & str) = False Then
FSO.MoveFile oDiv & "\" & str, oDiv & "\" & sFN & "\"
cnt = cnt +1
Else
FSO.DeleteFile oDiv & "\" & str, True
Dcnt = Dcnt +1
End If
Next
Tcnt = Tcnt + cnt
TDCnt = TDCnt + Dcnt
f1.Writeline(cnt & " File(s) Backed up.")
f1.Writeline(Dcnt & " Duplicate File(s) deleted.")
f1.WriteLine("----------------------------------------------------")
Set oFile = Nothing
Set oDiv= Nothing
End If
Next
f1.Writeline(Tcnt & " Total File(s) Backed up.")
f1.Writeline(TDcnt & " Total Duplicate File(s) deleted.")
f1.Close
Sum = TDcnt + Tcnt
wscript.echo Sum & " Statement Files Processed. Summary of which is being Emailed to CSD Help Desk."
End If
End Sub
Call BackupStatements