Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Run VBScript Via CMD and Scheduled Task

Avatar of benners70
benners70 asked on
Microsoft DOSVB Script
3 Comments1 Solution1577 ViewsLast Modified:
I am having problems running a VBScript via a task scheduler on a shared server.

I can get the attached VBScript to send an email fine via a Test Command button provided in the task scheduler admin but if I schedule the script it doesn't send. I have no error logs but I have been told the following by server admin staff:

"The 'Test Command' button will execute the script specified, with many pre-defined environment variables that may not be available when it's actually ran on the server in the scheduled task environment. Can we ask you review this script, and any variables that in my rely on being defined in the environment, are defined manually in the script, which should then resolve this issue."

I have been using the following CMD in a BAT file.
c:\Windows\System32\cscript.exe \\IIS0001\home\mysite.co.uk\public_html\vbTest\emailTest.vbs
Function sendMail(fromName, from, rcpt, subject, body)
	Set mail 	 = WScript.CreateObject ("CDONTS.NewMail")
	mail.From    = from &"("&fromName&")"
	mail.Subject = subject
	mail.To      = rcpt
	mail.BodyFormat = 0
	mail.MailFormat = 0
	mail.Body = body
	set mail = nothing
end function

sendMail "Web site", "admin@mysite.com", "paul@mysite.com", "CRON EMAIL TEST", "CRON EMAIL TEST"
Avatar of rejoinder
rejoinderFlag of Canada imageManager, IT
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers