Board index » Visual Studio » Newbie Needing Help

Newbie Needing Help

Visual Studio18
Hi there Group,



Hope somebody wouldn`t mind helping me out here?

I`ve Created the following VB Script:



Set objShell = CreateObject("WScript.Shell")

Dim FSO

Set FSO = CreateObject("Scripting.FileSystemObject")



dDate = Now

sDateTime = Year(dDate) & Right(100 + Month(dDate),2) _

& Right(100 + Day(dDate),2) & "_" & Right(100 + Hour(dDate),2) _

& Right(100 + Minute(dDate),2) & Right(100 + Second(dDate),2)



sFilename = sDateTime & ".zip"

'WScript.Echo sFilename



'Set a Backup job to PKZip

objShell.Run "C:\pkware\pkzip25\pkzip25 -add -path=relative

C:\zips\DataBackups\HFSdata" & sFilename _

& " c:\hfsdata\*.*"

objShell.Run "C:\pkware\pkzip25\pkzip25 -add -path=relative

C:\zips\DataBackups\BomTrans" & sFilename _

& " c:\bomtrans\*.*"

objShell.Run "C:\pkware\pkzip25\pkzip25 -add -path=relative

C:\zips\DataBackups\MyDocuments" & sFilename _

& " c:\Documents and Settings\%USERNAME%\My Documents\*.*"



'Delete OLD Data - This Keeps 7 Days worth of Backups

Set Folder = FSO.GetFolder("C:\zips\DataBackups\HFSdata")

For Each File in Folder.Files

If DateDiff("d", CDate(File.DateLastModified), Now())>7 Then

FSO.DeleteFile File

Next

Set Folder = Nothing

Set FSO = Nothing



Set Folder = FSO.GetFolder("C:\zips\DataBackups\BomTrans")

For Each File in Folder.Files

If DateDiff("d", CDate(File.DateLastModified), Now())>7 Then

FSO.DeleteFile File

Next

Set Folder = Nothing

Set FSO = Nothing



Set Folder = FSO.GetFolder("C:\zips\DataBackups\MyDocuments")

For Each File in Folder.Files

If DateDiff("d", CDate(File.DateLastModified), Now())>7 Then

FSO.DeleteFile File

Next

Set Folder = Nothing

Set FSO = Nothing



What I would like to do is at the end of the running, send e-mail to the

User to Tel Them the Filenames of the 3 Files Created, and Weather of Not

the backup was sucessfull of wether it failed. How would I go about this?

Like i said Im a newbie so would be greatfull if somebody could explain

simply for me?



Many Thanks

NSC


-
 

Re:Newbie Needing Help

www.microsoft.com/technet/scriptcenter/scripts/message/smtpmail/default.mspx">www.microsoft.com/technet/scriptcenter/scripts/message/smtpmail/default.mspx



ESP







"NOT_SO_CLEVER" wrote:



Quote
Hi there Group,



Hope somebody wouldn`t mind helping me out here?

I`ve Created the following VB Script:



Set objShell = CreateObject("WScript.Shell")

Dim FSO

Set FSO = CreateObject("Scripting.FileSystemObject")



dDate = Now

sDateTime = Year(dDate) & Right(100 + Month(dDate),2) _

& Right(100 + Day(dDate),2) & "_" & Right(100 + Hour(dDate),2) _

& Right(100 + Minute(dDate),2) & Right(100 + Second(dDate),2)



sFilename = sDateTime & ".zip"

'WScript.Echo sFilename



'Set a Backup job to PKZip

objShell.Run "C:\pkware\pkzip25\pkzip25 -add -path=relative

C:\zips\DataBackups\HFSdata" & sFilename _

& " c:\hfsdata\*.*"

objShell.Run "C:\pkware\pkzip25\pkzip25 -add -path=relative

C:\zips\DataBackups\BomTrans" & sFilename _

& " c:\bomtrans\*.*"

objShell.Run "C:\pkware\pkzip25\pkzip25 -add -path=relative

C:\zips\DataBackups\MyDocuments" & sFilename _

& " c:\Documents and Settings\%USERNAME%\My Documents\*.*"



'Delete OLD Data - This Keeps 7 Days worth of Backups

Set Folder = FSO.GetFolder("C:\zips\DataBackups\HFSdata")

For Each File in Folder.Files

If DateDiff("d", CDate(File.DateLastModified), Now())>7 Then

FSO.DeleteFile File

Next

Set Folder = Nothing

Set FSO = Nothing



Set Folder = FSO.GetFolder("C:\zips\DataBackups\BomTrans")

For Each File in Folder.Files

If DateDiff("d", CDate(File.DateLastModified), Now())>7 Then

FSO.DeleteFile File

Next

Set Folder = Nothing

Set FSO = Nothing



Set Folder = FSO.GetFolder("C:\zips\DataBackups\MyDocuments")

For Each File in Folder.Files

If DateDiff("d", CDate(File.DateLastModified), Now())>7 Then

FSO.DeleteFile File

Next

Set Folder = Nothing

Set FSO = Nothing



What I would like to do is at the end of the running, send e-mail to the

User to Tel Them the Filenames of the 3 Files Created, and Weather of Not

the backup was sucessfull of wether it failed. How would I go about this?

Like i said Im a newbie so would be greatfull if somebody could explain

simply for me?



Many Thanks

NSC







-