Archive for category VBScript

Calling the VBScript InStr function returns error

I am forced to work in classic ASP for some project. I don’t want to, it’s not my idea, but there we have it – the life of a consultant is fraught with peril.

While working on some VBScript code, I wrote some code to check permissions using the InStr function, and ran into this error:

Invalid procedure call or argument: 'InStr'

My call to InStr looked like this:

InStr(0, AllowablePermissions,UserPermissions)

According to , the first parameter, which was optional, defined the starting location. On a whim, I removed the first parameter, so my function call then looked liked this:


And it worked. Go figure.

1 Comment

Error: The “SendUsing” configuration value is invalid

That was the error I was receiving when trying to send an e-mail using CDONTS in a VBS script. But I found a post by Jeff on that was exactly what I was looking for.

The script was created to be run daily as a scheduled task, and to notify a user when disk space dropped below 15% of the drive’s total storage capacity.

This is the complete script, with comments at the end:
Option Explicit

Dim objFSO
Dim objDrive
Dim TotalSize
Dim AvailableSpace
Dim Percent
Dim objEmail

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objDrive = objFSO.GetDrive("C:")
AvailableSpace = objDrive.AvailableSpace
TotalSize = objDrive.TotalSize
Percent = (AvailableSpace / TotalSize) * 100
If Percent > 15 Then
 Set objEmail = CreateObject("CDO.Message")
 objEmail.From = ""
 objEmail.To = ""
 objEmail.Subject = "Server ZZZ is running low on disk space"
 objEmail.Textbody = "Server ZZZ is running low on disk space. " & AvailableSpace / 1024 & "MB is remaining of the total disk size of " & TotalSize / 1024 & "MB."
 objEmail.Configuration.Fields.Item("") = 2
 objEmail.Configuration.Fields.Item("") = ""
 objEmail.Configuration.Fields.Item("") = 25
End If

The script originally was created without these lines:

 objEmail.Configuration.Fields.Item("") = 2
 objEmail.Configuration.Fields.Item("") = ""
 objEmail.Configuration.Fields.Item("") = 25

The error was thrown at the objEmail.Send line. After adding the lines, it worked perfectly.

Leave a comment