DavidOverton.com
This site is my way to share my views and general business and IT information with you about Microsoft, IT solutions for ISVs, technologists and businesses, large and small.  
Scripts for Windows Vista Magazine

For this month's Windows Vista Magazine I discussed how to write a script to backup your documents folder and sending alert e-mails.  While there are a lot of places to go for help (links below), you will need the following for the following script copies to your user directory (%userprofile).  You can get to it by pressing start and literally typing %userprofile%.

Create a file called backup_script.cmd with the following:

@echo off
REM @echo off stops you seeing the individual backup commands executing
REM TITLE changes the title of the window
REM echo prints the text on your screen
REM the other commands are covered in the article
TITLE Documents Backup Routine
echo Do you want to do the backup – if not, press Ctrl-C
pause
RMDIR /s /q MD %userprofile%\docs_backups2
Move %userprofile%\docs_backups1 %userprofile%\docs_backups2
Move %userprofile%\docs_backups %userprofile%\docs_backups1
MKDIR %userprofile%\docs_backups
Robocopy %userprofile%\documents %userprofile%\docs_backups /s /z
exit

That is the first script.  The second script for sending e-mail is below (call it send_email.vbs):

Set objEmail = CreateObject("CDO.Message")
Set objArgs = Wscript.Arguments
If objArgs.Count <4 then
 Wscript.Echo "This command takes 4 parameters:"
 Wscript.Echo "1) Who is sending the e-mail - this should be your e-mail address"
 Wscript.Echo "2) Who is the e-mail going to - this could be your e-mail address or someone elses"
 Wscript.Echo "3) What is the subject line of the e-mail"
 Wscript.Echo "4) What will the e-mail say"
 Wscript.Quit
End If
objEmail.From=objArgs(0)
objEmail.To=objArgs(1)
objEmail.Subject=objArgs(2)
objEmail.Textbody=objArgs(3)

objEmail.Configuration.Fields.Item _
 ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "MY SMTP SERVER.COM"
objEmail.Configuration.Fields.Item _
 ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
 ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send

 

Thanks

 

David

 


Posted Sun, Oct 19 2008 10:47 PM by David Overton

Comments

Xcellerator Smith wrote re: Scripts for Windows Vista Magazine
on Thu, Nov 27 2008 6:38 PM

yeah, i tried chaning the parameters but nothing happened it still comes up with errors...

David Overton wrote re: Scripts for Windows Vista Magazine
on Fri, Nov 28 2008 6:26 PM

Xcellerator Smith, can you share the error messgaes with me, or even better, zip up the scripts you are running and send them to me ([email protected]) along with the command line.

Thanks

David

Add a Comment

(required)
(optional)
(required)
Remember Me?

(c)David Overton 2006-23