Persits ASPemail works from web pages but not when run as VBS script (from cmd line or scheduled task)

We have recently moved our website from WIn 2008 Server to a 64-bit Win 2012 server running IIS 8.  We have an auto billing script that runs each night. This is a simple VBS file that is run through the task scheduler. However, on the new server this script errors out on trying to instantiate the Persits.Mailsender object but ONLY when running directly on the server (either from the task scheduler or directly from the CMD line as Administrator). But it works fine when  instantiated through a web based ASP scipt (running obviously as IUSR).

I know the DLL is installed and registered correctly (because I can send email through web-based scripts). but not locally.

Here's a simple test script I wrote to test it:

			Set Mail = Server.CreateObject("Persits.MailSender")
			Mail.From = "" 
			Mail.Host = ""
			Mail.Subject = "Test"
			Mail.AddAddress ""
			strBody = "What's up?"
			Mail.Body = strBody

Open in new window

The above code, when run from the web (as an ASP file) works perfectly, however when run at the cmd line (as an admin, and with just CreateObject or WScript.CreateObject rather than Server.CreateObject) gives this:

Microsoft VBScript runtime error: ActiveX component can't create object: 'Persits.MailSender'

What the heck??

P.S. I have already changed the local script to use CDO instead, but I still want to know the answer to why this is behaving in this manner - and I'm willing to spend the points to ease my mind and hopefully help someone else in the future.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
Just a guess but is your ASP application running as 32 bit?
Is your VBScript also running as 32 bit process?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
worthyking1CTOAuthor Commented:
Doh! You're right, I'm running the website app pool in 32-bit compatibility mode, but was forgetting to open a 32-bit CMD window for testing.

Okay, so now I can run it from the (32 bit) cmd line, but how do I make the Scheduled Task run the target file in 32 bit mode? That's the real end-goal here anyway.

I tried setting the target to C:\Windows\SysWOW64\cmd.exe and tried various combos for arguments, such as:

cscript F:\mydir\test.vbs
/c F:\mydir\test.vbs
start F:\mydir\test.vbs
start "" F:\mydir\test.vbs

None of those worked.
worthyking1CTOAuthor Commented:
Okay, after trying a lot of different combos, I got it workings as follows:

Target:            C:\Windows\SysWOW64\cmd.exe
Argument:     /c "F:\mydir\test.vbs"

Thanks for pointing me in the right direction!
worthyking1CTOAuthor Commented:
Rainer led me to the answer ie. the command line running as 64-bit. I already knew the script & DLLs were 32-bit and had already configured IIS that way, so his answer pointed me to configuring the Task Scheduler to force the use of the 32-bit cmd.exe module.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.