Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

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

- - - - -

  • Please log in to reply
8 replies to this topic

#1
black~cobra

black~cobra

    Newbie

  • Member
  • 24 posts
  • Joined 10-January 04
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
Desktop: Custom:
P4C 2400 MHz SL6WF OEM RK80532PG056512 | Asus P4P800 DX BIOS-1010 | 2x256mb DDR400 Micron | Asus GF5 FX5200 VideoSuite | On board Sound | ViewSonic VE700 LCD 17" | Seagate 80Go Sata | Altec Lansing 621 | Antec PP1080AMG 430W | MS IntelliMouse Explorer 3.0 | Logitech Elite | Lite On DVD | Lite On CDRW | D-Link Di-614+ Router | Canon FB630U scanner | Nortel Network DSL Modem | 7515 3dmark 01SE


How to remove advertisement from MSFN

#2
zivan56

zivan56

    Advanced Member

  • Member
  • PipPipPip
  • 318 posts
  • Joined 15-June 02
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.

#3
black~cobra

black~cobra

    Newbie

  • Member
  • 24 posts
  • Joined 10-January 04

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
Desktop: Custom:
P4C 2400 MHz SL6WF OEM RK80532PG056512 | Asus P4P800 DX BIOS-1010 | 2x256mb DDR400 Micron | Asus GF5 FX5200 VideoSuite | On board Sound | ViewSonic VE700 LCD 17" | Seagate 80Go Sata | Altec Lansing 621 | Antec PP1080AMG 430W | MS IntelliMouse Explorer 3.0 | Logitech Elite | Lite On DVD | Lite On CDRW | D-Link Di-614+ Router | Canon FB630U scanner | Nortel Network DSL Modem | 7515 3dmark 01SE

#4
zivan56

zivan56

    Advanced Member

  • Member
  • PipPipPip
  • 318 posts
  • Joined 15-June 02
Remove the bracket in:
' /s')
Its not supposed to be there. I must have typed it in accidently.

#5
black~cobra

black~cobra

    Newbie

  • Member
  • 24 posts
  • Joined 10-January 04

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
Desktop: Custom:
P4C 2400 MHz SL6WF OEM RK80532PG056512 | Asus P4P800 DX BIOS-1010 | 2x256mb DDR400 Micron | Asus GF5 FX5200 VideoSuite | On board Sound | ViewSonic VE700 LCD 17" | Seagate 80Go Sata | Altec Lansing 621 | Antec PP1080AMG 430W | MS IntelliMouse Explorer 3.0 | Logitech Elite | Lite On DVD | Lite On CDRW | D-Link Di-614+ Router | Canon FB630U scanner | Nortel Network DSL Modem | 7515 3dmark 01SE

#6
zivan56

zivan56

    Advanced Member

  • Member
  • PipPipPip
  • 318 posts
  • Joined 15-June 02
No problem, I'm glad to see people interested in learning Delphi :)

#7
black~cobra

black~cobra

    Newbie

  • Member
  • 24 posts
  • Joined 10-January 04

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
Desktop: Custom:
P4C 2400 MHz SL6WF OEM RK80532PG056512 | Asus P4P800 DX BIOS-1010 | 2x256mb DDR400 Micron | Asus GF5 FX5200 VideoSuite | On board Sound | ViewSonic VE700 LCD 17" | Seagate 80Go Sata | Altec Lansing 621 | Antec PP1080AMG 430W | MS IntelliMouse Explorer 3.0 | Logitech Elite | Lite On DVD | Lite On CDRW | D-Link Di-614+ Router | Canon FB630U scanner | Nortel Network DSL Modem | 7515 3dmark 01SE

#8
zivan56

zivan56

    Advanced Member

  • Member
  • PipPipPip
  • 318 posts
  • Joined 15-June 02
Look at this site:
http://delphi.about....ly/aa082499.htm
Specifically under "Execute a program and wait until it has finished"
Delphi.about.com is one of the best sites to learn Delphi from.

#9
black~cobra

black~cobra

    Newbie

  • Member
  • 24 posts
  • Joined 10-January 04

Look at this site:
http://delphi.about....ly/aa082499.htm
Specifically under "Execute a program and wait until it has finished"
Delphi.about.com is one of the best sites to learn Delphi from.

Thanks again :rolleyes:

Have a good night :)

Black~Cobra
Desktop: Custom:
P4C 2400 MHz SL6WF OEM RK80532PG056512 | Asus P4P800 DX BIOS-1010 | 2x256mb DDR400 Micron | Asus GF5 FX5200 VideoSuite | On board Sound | ViewSonic VE700 LCD 17" | Seagate 80Go Sata | Altec Lansing 621 | Antec PP1080AMG 430W | MS IntelliMouse Explorer 3.0 | Logitech Elite | Lite On DVD | Lite On CDRW | D-Link Di-614+ Router | Canon FB630U scanner | Nortel Network DSL Modem | 7515 3dmark 01SE




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users