Sunday, 15 April 2012

delphi - What is the proper way to execute a batchfile with multiple params? -


I have a batch file that I use to manage the translation of various programs. Now I want a Delphi application to call this batch file and pass the required parameters for further processing. Unfortunately, there are spaces in the parameter, which is due to a partition. Is there any way to keep the intention of all the parameters? This is where my batchfile looks:

  ECHO scans new ressources% MLDIR% \ Ml7Build.exe% 1% ECHO import new translation% MLDIR% \ MlBuild.exe I% 2 Create the ECHO translation application for the dictionary for%% MLDIR% \ Ml7Build.exe b% to 3%  

Because I found many similar questions on ShellExecute from ShellApi-Command Tried to use, but none of them can help me solve my problem My Delphi code looks like this:

  param1: = ExtractFileName (hMLProj); Param2: = '-f:' + MLWorkDir + 'Previous _' + ExtractFileName (hMLProj) '-settings: Auftrag_Test.importsettings- Method: 2 -overwri: 3-Error: 2' + ExtractFileName (hMLProj) + '; Param3: = ExtractFileName (hMLProj); ShellExecute (0, 'open', PCHAR (MLWorkDir + '__automatedTranslationFUBAR.bat'), PChar (param1 + param2 + param3), zero, SW_SHOWDEFAULT);  
  ECHO scans for new resources% MLDIR% \ Ml7Build.exe s Import terminology for% ~ 1 ECHO new translation%% MLDIR% \ MLBUld.exeI% ~ 2REM7 ^ is omitted? Please note that % n   not  % N%  (n = 1..9) Removes the specified parameter for the batch  n  tilde "any enclosed quote." 

The parameters need to be "enclosed in quotation" (and they should be double quotes) if they include spaces like separator.


No comments:

Post a Comment