Microsoft Script Control 64 bit?
Asked Answered
Q

3

5

Is there any msscript control in 64 bit? I google a bit and all say no 64-bit yet

The reason that I need 64bit msscript.ocx is that I want to compile delphi projects in 64-bit using XE3.

It compiles OK in XE3 and I have obtained a 64-bit exe but when it executes to the following line,

  script := TScriptControl.Create(nil);

It gives me a 'Class Not Registered' error. I only found msscript.ocx under C:\windows\SysWOW64 but there is no such file under System32 folder.

I really want this to work so any quick replacement for this?

Qualm answered 21/3, 2013 at 13:46 Comment(0)
Q
7

This is an old post. but I just found a very good alternative to 64-bit MSScript Control (Microsoft does not have 64-bit msscript.ocx)

http://www.eonet.ne.jp/~gakana/tablacus/scriptcontrol_en.html

and I have changed only a few lines of code in my application and it works in 64-bit based on this ScriptControl64.

Qualm answered 4/9, 2015 at 12:1 Comment(3)
This control seems to work, but I can't get Visual Studio 2015 to accept it as a valid COM object. When I just leave the original 32 bit MS Script control reference in the project when Tablacus is registered alongside with it, VS will compile my app for AnyCPU and x86, but TlbImp gives an error "A single valid machine type compatible with the input type library must be specified" when I try to compile for X64. When I try to add the dll as a reference directly (browse), Visual Stdio says it can't add it.Duero
Re my previous comment: it really works, doesn't just "seem to". My app, with reference for MSScript.ocx and compiled for AnyCPU, autamtically uses this 64 bit dll if it is installed (registered), no source code changes necessary. When the dll isn't installed,it fails as expected because it's running in 64 bit mode and only the 32 bit version is there. So the only problem is getting Visual Studio to accept it too.Duero
It also worked with zero code change using Late Binding in my VBA 64-bit project (Access and Excel). Early Binding, however, I couldn't manage to set, not even when trying to reference the tsc64.dll file directly.Dincolo
L
3

The msscript component was not ported to 64 bit. It's a legacy component and MS chose not to put the effort into migrating it to 64 bit. You'll simply need to find another way to do whatever it is you do with that component.

List answered 21/3, 2013 at 13:52 Comment(4)
And this is the reason I avoid external controls like the plague - I got bit in the rear many times years ago by that moving target that was TWebBrowser or whatever it is called now.Gush
Funny fact is that InternetExplorer has been ported to 64 bits: support.microsoft.com/kb/896457/enGenisia
I find your changing the accepted answer to be a little disappointing. You asked "Is there any msscript control in 64 bit?". I answered.List
@David Heffernan with all respect, i also asked " so any quick replacement for this?" and simply answering 'no' is not good enough now.Qualm
A
1

I faced the same issue porting an c++ application from 32 to 64 Bit. I know that this question was raised on Delphi but I hope someone can make use of this information or transfer it to other languages.

We where initiating the "ScriptControl" (MSScriptControl.ScriptControl.1) via CreateDispatch. The control info is located in Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ScriptControl and we executed VBS or JScript with this MS control in 32 Bit:

COleDispatchDriver* m_dispScriptControl = new COleDispatchDriver();
if (m_dispScriptControl)
{
   if (m_dispScriptControl->CreateDispatch(_T("ScriptControl")))
   {
     ...
     .... setting language to be used and other proteries .. then execute script code:

      _variant_t varResult;
      VariantClear(&varResult);
      EXCEPINFO    excepinfo;
      VARIANT parameters;
      parameters.vt = VT_BSTR;
      parameters.bstrVal = strScriptCodeWCHAR;

      DISPPARAMS dispparams;
      dispparams.rgdispidNamedArgs = NULL;
      dispparams.cNamedArgs = 0;
      dispparams.cArgs = 1;
      dispparams.rgvarg = &parameters;
      unsigned int uArgErr = 0;

      if (S_OK != m_dispScriptControl->m_lpDispatch->Invoke(0x7d2, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &dispparams, &varResult, &excepinfo, &uArgErr))
...

   }

After some research it seems not to be possible to create the ScriptControl in 64 bit application as of a MSDN query:

Question was: I have window forms application currently working fine on 32 Bit Application and i am investigation so we can install it on a 64 bit computer but getting on lauching the application as below.

Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

The error is located on AxInterop.MSScriptControl.dll

Awnser is: If it ONLY lives in C:\Windows\SysWOW64, then your .Net application cannot run in 64-bit mode. Make sure you compile it for x86 instead of Any CPU. Then you'll be able to use it in 64-bit Windows, but it will be a 32-bit process.

https://social.msdn.microsoft.com/Forums/windows/en-US/1e9ddfe4-3408-4a34-ba43-a1a0931daebd/64-bit-windows-7?forum=clr

With which we where not happy as we want to run as 64-bit process

Our solution was to use the Microsoft IActiveScript Interface. And implemented the same on our main window:

BEGIN_INTERFACE_PART(ActiveScriptSite, IActiveScriptSite)
        STDMETHOD(GetLCID)(LCID*);
        STDMETHOD(GetItemInfo)(LPCOLESTR, DWORD, LPUNKNOWN*, LPTYPEINFO*);
        STDMETHOD(GetDocVersionString)(BSTR*);
        STDMETHOD(OnScriptTerminate)(const VARIANT*, const EXCEPINFO*);
        STDMETHOD(OnStateChange)(SCRIPTSTATE);
        STDMETHOD(OnScriptError)(IActiveScriptError*);
        STDMETHOD(OnEnterScript)();
        STDMETHOD(OnLeaveScript)();
END_INTERFACE_PART(ActiveScriptSite)

Now when we have to execute script code we do the following, which works fine in 64 and 32 BIT versions of our built:

 CString strLanguage;
 if (nLanguage == 1)
 {
    strLanguage = _T("VBScript");
 }
 else
 {
   strLanguage = _T("JScript");
 }
    
CComPtr<IActiveScript> m_pAxsScript;
HRESULT hr = m_pAxsScript.CoCreateInstance(CT2W(strLanguage), NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER); 
    
m_pAxsScript->SetScriptSite(&m_xActiveScriptSite); //m_xActiveScriptSite is a member of the interface

CComQIPtr<IActiveScriptParse> m_pAxsScriptParse = m_pAxsScript;

m_pAxsScriptParse->InitNew();


EXCEPINFO pException = { 0 };
hr = m_pAxsScriptParse->ParseScriptText(_bstr_t(strCode), 0, NULL, NULL, dw, 0, 0, NULL, &pException);

//execute script
m_pAxsScript->SetScriptState(SCRIPTSTATE_CONNECTED);

m_pAxsScriptParse.Release();
m_pAxsScriptParse = nullptr;

hr = m_pAxsScript->SetScriptState(SCRIPTSTATE_DISCONNECTED);
ASSERT(hr == S_OK);

m_pAxsScript->Close();
m_pAxsScript.Release();
Autocephalous answered 30/6, 2021 at 16:1 Comment(2)
related question for IActiveScript implementation / usage in c++ #7492368Autocephalous
related question for IActiveScript impmentation in delphi https://mcmap.net/q/752464/-hosting-wsh-vbscript-javascript-in-your-delphi-applicationAutocephalous

© 2022 - 2024 — McMap. All rights reserved.