1

I have a vbs script on my local pc that I can run by double clicking on it. The scripts runs fine.

I have a php page that if requested tries to run the very same vbs script. Issue is that when my php runs it calls my vbs script and fails when it gets to a point where it needs to create an object.

How do I go about creating my object if I'm calling the vbs script from php.

PHP Code.

$command = 'wscript.exe C:/eClaimsAPI/SendToTelus.vbs';

/*
 * wait for command to return a exit code?
 *
 * true = waits for the command to complete, before continuing this script
 * false = executes command then continues this script without waiting for command to exit
 *
*/

$wait = true;


// run it

$obj = new COM ( 'WScript.Shell' );

if ( is_object ( $obj ) )
{
    $obj->Run ( 'cmd /C ' . $command, 0, $wait );
}
else
{
    echo 'can not create wshell object';
}

$obj = null;

VBS Code

Dim nErr

Dim szXML

Dim strMsgType

Dim ID

Dim ID2
Dim oServer

Set TypeLib = CreateObject("Scriptlet.TypeLib")
ID = TypeLib.Guid
ID = Replace(ID,"{","")
ID = Replace(ID,"}","") 

Set oServer  = WScript.CreateObject("eCLaimsAPI.Api")

Issue happens on the last line where ( Set oServer )

Error: Could not create object named "eClaimsAPI.Api" Code: 80040154 Source: WScript.CreateObject

Tolure
  • 859
  • 1
  • 14
  • 34
  • Since this error I've learned that 80040154 is a class not registered. Anyone know why one would get this error when running their vbs from php and not from double clicking the .vbs file? – Tolure Sep 06 '17 at 23:48
  • 1
    Bit-age is likely to be the issue. Does PHP run in a 32-bit process or a 64-bit? If I was to guess, the reason the VBS works on its own is that it gets called through the OS using the default bit-age which is probably going to be 64-bit. If PHP is running in 32-bit it will start the VBS in 32 bit. Remember COM DLL can be registered in both the 32 bit and/or 64-bit registries. See [this answer](https://stackoverflow.com/a/35985827/692942) which breaks down COM DLL registration for you. – user692942 Sep 07 '17 at 07:56
  • Thank you for the information. – Tolure Sep 07 '17 at 15:41

1 Answers1

0

Thanks to Lankymart I was able to solve this issue.

After a little more digging and researching I found that my specific issue ended up being that my application pool > advanced settings > Enable 32-Bit Applications was set to true. Turning it off solved my problem.

Tolure
  • 859
  • 1
  • 14
  • 34