Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 

Sign in to follow this  
black~cobra

How to start an command or cmd file in delphi 7 ?

Recommended Posts

black~cobra    0

Hi guys,

I would like to know how to start a ".cmd file" or how to execute a "command" (--> like "start /wait %cdrom%\install\program.exe /switch" from when i click on a button ?

Let me explain:

I am making an application in Delphi 7 that would install all the programs that i want, all unattended. I want to use Delphi 7 because that's what i learning in college now, i need your help on this one because my teacher is just a dumb guy that want is paycheck at the end of the week, he is not really good either :),

Here is what happen when i click on the button

procedure TPost_Install.OkClick(Sender: TObject);
begin
 ShowMessage('Post-Installation will install your selected applications);
 My problem is here--> How to call a file and execute it or execute a command ???
end;

And, the help file is no good too :/

Can you help me ?

Thanks to anyone that can help me :rolleyes:

Black~Cobra

Share this post


Link to post
Share on other sites
zivan56    0

ShellExecute(Handle ,'open', 'C:\install\program.exe', ' /switch'),  nil, SW_SHOWNORMAL);

Would run the program with a switch. You probably didnt learn it because it is a Windows API call, and therefore requires the shellapi in the uses section.

Share this post


Link to post
Share on other sites
black~cobra    0
ShellExecute(Handle ,'open', 'C:\install\program.exe', ' /switch'),  nil, SW_SHOWNORMAL);

Would run the program with a switch.  You probably didnt learn it because it is a Windows API call, and therefore requires the shellapi  in the uses section.

Thanks alot for your response. I really appreciate it :) , but when i try to execute it , i get an error. :/

I added the "shellapi" in the uses section and your code in the code i posted in my first post and it comes up as an error saying : "not enought originals parameters" . Sorry if this doenst sound right, i use a french version of Delphi.

Here the code that i added to my program:

uses
 shellapi, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;

procedure TPost_Install.OkClick(Sender: TObject);
begin
ShowMessage('Post-Installation will install your selected applications);
ShellExecute(Handle ,'open', 'C:\aaw6.exe', ' /s'),  nil, SW_SHOWNORMAL);
end;

Thanks again for your help !!

Black~Cobra

Share this post


Link to post
Share on other sites
black~cobra    0
Remove the bracket in:

' /s')

Its not supposed to be there.  I must have typed it in accidently.

I love you zivan56 :rolleyes:

Its working !!! My little application is working like it should.

:punk:

Thanks alot for replying to my Questions :)

Black~Cobra

Share this post


Link to post
Share on other sites
black~cobra    0
No problem, I'm glad to see people interested in learning Delphi  :D

Last question , I promise :rolleyes: ,

how would i add the "start /wait" command to the code you gave me earlier ?

I need that command line because all the application are trying to install at the same time ! And not like one at a time like I thought it should be ?

Thanks again :)

Black~Cobra

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×