Forum Discussion

francescof's avatar
francescof
Occasional Visitor
7 years ago

How to use ShellExecute in DelphiScript?

I am trying to write my first DelphiScript Script:

 

procedure initializeDatabaseForTesting;
begin
ShellExecute(0, nil, 'cmd.exe',
'sqlcmd -S mypc\express2014 -i C:\TestComplete\tests\restoredb.sql', nil, SW_HIDE);
end;

 

when i run it it asys "Undeclared identifier ShellExecute".

 

in Delphi ShellExecute is deinfed in Shellapi, how to do "uses Shellapi" in Delphiscript?

 

Thanks.

1 Reply

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    This is DelphiScript... not Delphi... so, if there are certain commands, modules, etc., that are part of the Delphi IDE environment, they are not going to be here.

     

    Based upon what you are wanting to do, you should look into using the WshShell object that's built into TestComplete and utilize the Exec method on that object.  Your code might then look something like


    procedure initializeDatabaseForTesting;
    begin
    WshShell.Run('cmd.exe \c sqlcmd -S mypc\express2014 -i C:\TestComplete\tests\restoredb.sql)
    end;