«

»

Nov 20

Print this Post

Create alert in VBScript Monitor file share folder drop

Create alert in VBScript Monitor file share folder drop.

Script:

SET oShell = CREATEOBJECT(“Wscript.Shell”)

myCommand = “cmd.exe /c DIR /o-d /b \\serverName\D$\myfolder\”
‘myCommand = “cmd.exe /c Robocopy
mydate= Replace(FormatDateTime(date),”/”,”_”)
‘mydate= “8_26_2011″

‘MSGBOX(myCommand)
‘MSGBOX(mydate)

SET oExec = oShell.Exec(myCommand)

DO UNTIL oExec.StdOut.AtEndOfStream
outputline = outputline &Chr(9)& oExec.StdOut.ReadLine& Chr(10)
‘MSGBOX(outputline)
IF inStr(outputline,mydate)<>0 THEN
outputline = “<Green>Log Folder “&mydate&” found”
mySubject= “Testing(Please Ignore): “& outputline& “** Folder Monitoring **”
‘MSGBOX(outputline)

ELSE
outputline = “<RED>Log Folder “&mydate&” is missing.”
‘MSGBOX(outputline)
mySubject= “Testing(Please Ignore): “& outputline& “** Folder Monitoring **”
END IF
Exit Do

LOOP
‘SET oExec = NOTHING
Set objMessage = CreateObject(“CDO.Message”)
objMessage.Subject = mySubject
objMessage.From = “from@abc.com”
objMessage.To = “to@abc.com”
objMessage.TextBody = outputline
‘objMessage.AddAttachment “C:\Users\abc\Desktop\output.txt”
‘==This section provides the configuration information for the remote SMTP server.
‘==Normally you will only change the server name or IP.

objMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2

‘Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = “smtpserver01″

‘Server port (typically 25)
objMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = 25

objMessage.Configuration.Fields.Update

‘==End remote SMTP server configuration section==

objMessage.Send

 

 

 

Permanent link to this article: http://www.techxpress.in/create-alert-in-vbscript-monitor-file-share-folder-drop/

Bookmark this page