DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Using ScriptStart in VC++ doesn't seems to be working.

 
Hi,
 
I am a software a developer.  I am using Diadem 9.x evaluation version.  While I try to run Scriptstart function in VC++ using OLE.  It seems its failing.  The below is the code sequence.
 
Please help,

ITOCommand dispToCmd ;
COleVariant oleVariant;

if( dispToCmd.CreateDispatch("diadem.tocommand", err) == FALSE)
{
pServer->m_log << "DIAdem Instancing Failure. \n";
throw err;
}
dispToCmd.SetBNoMsgDisplay( TRUE );
pServer->m_log << "Message display disabled in DIAdem. \n";
dispToCmd.SetBNoErrorDisplay( TRUE );
pServer->m_log << "Error display disabled in DIAdem. \n";
Sleep(4000);
oleVariant = _T("");
oleVariant = _T("T1:='"+ _bstr_t(pServer->m_strJobId) +"'");
oleVariant = _T("");
oleVariant = _T("ScriptStart('D:\\Test.VBS')");
CoUninitialize(); // Uninitialize the COM Library
 

Thanks,
Subbaraj.
 
0 Kudos
Message 1 of 26
(7,043 Views)
Hello Subbaraj!
 
I'm missing a call to 'CmdExecuteSync' or 'CmdExecuteAsync'.
 
Try this code before CoUnitialize:
 
oleVariant = _T("ScriptStart('D:\\Test.VBS')" );
dispToCmd.CmdExecuteSync(oleVariant);
 
My Test with 9.1 were successful!
 
Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 2 of 26
(7,036 Views)
Sorry for that copy-paste error,  The code was already there.
 
dispToCmd.CmdExecuteSync(oleVariant);
 
This seems not working,  Is it because of Evaluation version of 9.x ?
 
I am trying to open a text file and write some information using VB Script.
 
Please suggest.
 
Thanks,
Subbaraj.
 

0 Kudos
Message 3 of 26
(7,023 Views)
Hello Subbaraj!
 
If DIAdem is already running and the evaluation dialog is closed this should be no problem. You can ensure that DIAdem is able to process OLE commands by waiting for the interface flag 'bInterfaceLocked' to be false before the first 'real' call.
 
Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 4 of 26
(7,020 Views)

Matthias:

 

I have a similar problem.  I am running the same code, and it fails on the dispToCmd.CreateDispatch statement:

if( dispToCmd.CreateDispatch("diadem.tocommand", err) == FALSE)

{

pServer->m_log << "DIAdem Instancing Failure. \n";

throw err;

}

 

Do you, or does anyone have an idea how to fix this.

 

Tom

0 Kudos
Message 5 of 26
(6,811 Views)

Hello Tom!

 

Have you run DIAdem with admin rights after installing? This is necessary to register the DIAdem OLE Server.

 

If you did it please try this  VBS code in Windows (Paste it to a file with a vbs extension and doubleclick it in the explorer):

Option Explicit

Dim oToCommand

Set oToCommand = CreateObject("DIAdem.ToCommand")

 

 

You can also check the registration in the registry. Try to find out if this Key HKEY_CLASSES_ROOT\CLSID\{285E4FB2-F633-11D1-85DC-008048D9A408}\LocalServer32 exists and its value is your DIAdem executable.

 

Matthias

Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 6 of 26
(6,805 Views)

Matthias:

 

Thanks for the reply!

 

I am running as admin.

 

I ran the script that you sent, but did not see any output.  It ran for about 12 seconds and consumed memory and CPU.

 

The key that you questioned is in the registry.

 

Tom

0 Kudos
Message 7 of 26
(6,803 Views)

Matthias:

 

When I run the VBS script as you recommended, Diadem starts, and then exits after about 12 seconds.

 

When I try to execute my code, Diadem starts, runs for abnout 12 seconds, and does not exit.  I have to use task manager to end the process.

 

Tom

0 Kudos
Message 8 of 26
(6,798 Views)

Hello Tom!

 

The script does the same as your C++ code. No output means no error! The time is consumed because DIAdem is started in the background. At the moment I have no idea anymore what causes your C++ code to crash. I have a test program in my office. I will try it tomorrow and give you feedback.

 

Matthias

Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 9 of 26
(6,797 Views)

Hello Tom!

 

Can you please try this code instead and report the content of the messagebox:

ITOCommand    dispToCmd ;
COleException oEx;

if( dispToCmd.CreateDispatch( (LPCTSTR)_T("diadem.tocommand"), &oEx) == FALSE)
{
  oEx.ReportError();
  return;
}

Matthias

Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 10 of 26
(6,773 Views)