Active-X error CreateObject("ScriptControl")

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Alfredo73
    New Member
    • Feb 2009
    • 12

    Active-X error CreateObject("ScriptControl")

    Hi,

    I have a Visual Basic application using Createobject("S criptControl") to convert a user input like 3+3 to 6. This worked perfect under Windows XP and even Windows 7 but on my new Windows 2008 Server (64 bit) it gives an error: Cannot Create ActiveX component. Should I register or refer anywhere ? Should I install anything ?

    Code:
    Dim SControl = CreateObject("ScriptControl")
    SControl.language = "VBScript"
    Totalfee = SControl.eval(TotalfeeTextBox.Text)
    I hope anybody can help me !

    Freddie
  • !NoItAll
    Contributor
    • May 2006
    • 297

    #2
    Alfredo:
    There are TWO things you need to be aware of.
    1. You need to deploy MSSCRIPT.OCX with your application. There are no dependencies for it apparently, but you should still deploy the MSSCRIPT.DEP with it.
    2. It is only a 32 bit control so any program you use with it must be x86 ONLY. Creating an assembly that JITs to a native 64 bit app will NOT work.

    Also - if you are using it in vbscript it gets tricky - because, by default, any vbs script on a 64-bit OS will execute as a native 64 bit application. This means that any objects created from 32-bit DLLs or ActiveX (OCX) files simply will not work. To use those 32 bit components on a 64 bit system you have to execute the .vbs script using the cscript.exe that is located inside the SysWOW64 folder on the 64-bit system.

    c:\SysWOW64\csc ript myscript.vbs

    Simply double clicking on a vbs script will not work. You might try to get fancy and see if you can rename a script from xxx.vbs to xxx.s32 and register it for the syswow64 copy of cscript...

    I have heard tales of folks copying the cscript.exe from syswow64 to the c:\windows\syst em folder - but I'm dubious... That will likely break more than it fixes. That would actually be a very bad thing to do as vbs scripts are used by more applications then you might think - including MANY installers! If you force all VBS scripts to run as 32 bit - then they will not be able to create any 64-bit objects.

    Comment

    • Alfredo73
      New Member
      • Feb 2009
      • 12

      #3
      Originally posted by !NoItAll
      Alfredo:
      There are TWO things you need to be aware of.
      1. You need to deploy MSSCRIPT.OCX with your application. There are no dependencies for it apparently, but you should still deploy the MSSCRIPT.DEP with it.
      2. It is only a 32 bit control so any program you use with it must be x86 ONLY. Creating an assembly that JITs to a native 64 bit app will NOT work.

      Also - if you are using it in vbscript it gets tricky - because, by default, any vbs script on a 64-bit OS will execute as a native 64 bit application. This means that any objects created from 32-bit DLLs or ActiveX (OCX) files simply will not work. To use those 32 bit components on a 64 bit system you have to execute the .vbs script using the cscript.exe that is located inside the SysWOW64 folder on the 64-bit system.

      c:\SysWOW64\csc ript myscript.vbs

      Simply double clicking on a vbs script will not work. You might try to get fancy and see if you can rename a script from xxx.vbs to xxx.s32 and register it for the syswow64 copy of cscript...

      I have heard tales of folks copying the cscript.exe from syswow64 to the c:\windows\syst em folder - but I'm dubious... That will likely break more than it fixes. That would actually be a very bad thing to do as vbs scripts are used by more applications then you might think - including MANY installers! If you force all VBS scripts to run as 32 bit - then they will not be able to create any 64-bit objects.
      Hi NoItAll,

      Thanks for your reply. I was on holiday so could not respond earlier. I am not too good with Visual Basic so do not understand your reply. Can you please help me further. The Visual Basic application is installed on my X64 system itself, it is not used for distribution. Seen from the Visual Basic application, if I am in the debugger, can you please explain me how I should change my script ? I do not understand where to use the c:\SysWOW64\csc ript myscript.vbs... ..

      Hope you or anyone can help me.

      Regards,

      Alfred

      Comment

      Working...