Programming, Solution

VBScript: Folder Monitoring


There’s a scenario where there’s an active folder where files are coming in and out, so the key objective of the program is to ensure that the folder always stay empty. Any files that stay more that 30 minutes is consider an alert and it needs to be taken care of and the alert will be sent through email.

So below are the code and it is triggered every 15 minutes using the Task Scheduler :

Note: The Outlook application has to be running, otherwise it will go to the outbox folder and the mail will be sent after the outlook application is running

age_threshold = 30 'in minutes

folderPath = "path"

Set fso = CreateObject("Scripting.FileSystemObject")
Set fldr = fso.getFolder(folderPath )

file_found = 0

Set shell = wscript.CreateObject("Shell.Application")

For Each fl in fldr.Files
age = DateDiff("n", fl .DateCreated, Now)
If age > age_threshold Then
file_found = file_found+1
End If
if file_found > 0 then
end if

sub sendAlert(no)
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
objMail.Display 'To display message
objMail.To = ""
objMail.Subject = "Alert: Folder XYZ"
objMail.Body = "Please check the XYZ folder - "&folderPath
Set objMail = Nothing
Set objOutlook = Nothing
end sub

-Farrah K.

Programming, Solution

VBScript: Content Search


I used to write codes in Visual Basics, it was long time ago. Never thought that I will use it again until recently with my current job which using VBScript. For my understanding is that VB is more to application while VBS is more to script language that runs command, more like a batch file. In another word, VBS is the light version of VB. (in a sense haha)

For the first time, I was given a sample before I write it then after writing it I quite surprise VBS can do a lot with the files which I have been doing it manually years ago when I was in my uni. Some of the things that I wish I knew it back then so I could just write it and let the task scheduler do the works haha.

OK, so one of the tasks that have given to me was to search for numbers among 100-500++ files. So what I did was I wrote the code below which I called it “smart lookup” hehe… Below are just the small chunk of it but definitely a keeper:

num= InputBox("Please enter the number","Look for")
Set result Set fldr = fso.GetFolder(folderpath)
Set fls = fldr.Files
Set d=CreateObject("Scripting.Dictionary")

For Each fl In fls
Set r= fl.OpenAsTextStream(1)
content = r.ReadAll
if instr(1,content,num) then
d.Add "a" & n,
end if


set w= result.CreateTextFile("result.txt") 'put all the result into this file, just in case it appears in multiple files
if counter>0 then
For i=0 to counter-1
w.WriteLine allRslt(i)
end if

So this is just one of it that I’ve done and it’s quite handy.. Next post I’ll share you another task using VBScript

-Farrah K.

Installation, Solution

SharePoint 2016 Prerequisite installation error

So trying out the SharePoint 2016, while installing the prerequisite I’ve encountered that it was unable to install the Microsoft Information Protection and Control Client 2.1 as shown below:

sp error

So I went through the web and found this link:

Just download it, install and run the prerequisite again

Then another error I have encountered was that it unable to install the .NET Framework 4.6

So here’s the link: – make sure your windows updates are updated

And re-run again the SharePoint prerequisite.

That’s it for me.

-Farrah K.