Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 12-11-2006, 01:41 AM
praveenkumar_k praveenkumar_k is offline
Senior Member
 
Join Date: Sep 2006
Posts: 698
Default Run exe with parameters

Hi,
i need to build an application with function like copy files from source path to destination path. If i run the application from command prompt like

cpoyfile.exe
it should ask for Spath and DPath, If i gave it, it should copy files from sPath to Dpath

Help

TIA

Have a nice & Peaceful Day My Friend

Regards
KPK
Reply With Quote
  #2  
Old 12-11-2006, 01:49 AM
MerijnB MerijnB is offline
Senior Member
 
Join Date: Mar 2001
Posts: 452
Default RE: Run exe with parameters

with ParamCount() you can find out how many arguments you got form the commandline.
With ParamStr() you can get the different arguments, ie: ParamStr(1) gets the first argument.
Keep in mind that ParamStr(0) returns the path of your own executable.
Reply With Quote
  #3  
Old 12-11-2006, 02:55 AM
praveenkumar_k praveenkumar_k is offline
Senior Member
 
Join Date: Sep 2006
Posts: 698
Default RE: Run exe with parameters

can u give me sample code

Have a nice & Peaceful Day My Friend

Regards
KPK
Reply With Quote
  #4  
Old 12-11-2006, 03:17 AM
MerijnB MerijnB is offline
Senior Member
 
Join Date: Mar 2001
Posts: 452
Default RE: Run exe with parameters

assuming you call your application like this:

Code:
yourapp.exe c:\*.* d:\*.*
[delphi]
var Source, Dest: string;
begin
if ParamCount < 2 then // first check if we have enough arguments (2)
halt(1); // if not abort

Source := ParamStr(1); // get the 1st argument (source)
Dest := ParamStr(2); // get the 2nd argument (destination)
end;
[/delphi]
Reply With Quote
  #5  
Old 12-11-2006, 04:09 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,335
Default RE: Run exe with parameters

Example???

Did you try looking in the delphi help, there's a sample inside !!!

Objective reality is a delirium caused by lack of alcohol in blood.
There is no place like 127.0.0.1
Reply With Quote
  #6  
Old 12-11-2006, 04:52 AM
digitiger digitiger is offline
Senior Member
 
Join Date: Jan 2001
Posts: 716
Default RE: Run exe with parameters

I think you need to clarify your question because at one place you mention the parameters while in another line you say that application should ask for the values. These are two different things. If you needs parameters then it will be like windows command where you have to specify the command name and all the parameters in single line and if the given command line does not supplies all the expected values then the command exits with some error message.

While in the second case, it is like a batch script. when user types the name of the batch script, it prompts the user for first input value and when user gives valid value for first input then it asks for second input and so on and finally when it has all the values it does the expection function.

In view of the above, please clarify your question again
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 04:26 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.