Ask a Question

How to use ShellExecute in DelphiScript?

francescof
Occasional Visitor

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 1
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;

 


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
cancel
Showing results for 
Search instead for 
Did you mean: