Click here to Skip to main content
15,436,765 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
Anyone knows how to create and write batch file in inno setup or Edit batch file in inno setup?
Posted
Updated 31-Oct-19 0:13am
Comments
skydger 17-Oct-12 3:28am    
If there's no such a plug-in, I suppose it is not possible. Inno Setup is a setup 'compiller', so you have to use third-party editors such Notepad or others to create such files.

Hello,

Actually it is possible if you use the [code] section and write your own code.

Delphi
[Code]
function CreateBatch(): boolean;
var
  fileName : string;
  lines : TArrayOfString;
begin
  Result := true;
  fileName := ExpandConstant('{pf}\{#MyAppName}\batch.bat');
  SetArrayLength(lines, 3);
  lines[0] := 'echo hello';
  lines[1] := 'pause';
  lines[2] := 'exit';
  Result := SaveStringsToFile(filename,lines,true);
  exit;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if  CurStep=ssPostInstall then
    begin
         CreateBatch();
    end
end;


Valery.
 
Share this answer
 
Comments
Nirali R shah 18-Oct-12 6:48am    
Hi, Thank you very much for the code... now i am running this batch.bat file in [run] section but it is not running.. i dont know where i am wrong.. please help me...Thanks in advance.
Nirali R shah 18-Oct-12 7:46am     CRLF
solved ... i have called CreateBatch() without any condition. procedure CurStepChanged(CurStep: TSetupStep); begin CreateBatch(); end;
Valery Possoz 18-Oct-12 9:13am    
CurStep let's you select at which point you want to perform the operation. CurStep=ssInstall means just before the installation starts,CurStep=ssPostInstall means just after the installation finishes CurStep=ssDone means just before Setup terminates. Anyway happy that you made it work. :)
Valery Possoz 14-Sep-18 13:44pm     CRLF
use the [run] section for this purpose. [Run] Filename: "{app}\batch.bat"; see here: http://www.jrsoftware.org/ishelp/index.php?topic=runsection
[code]
procedure CurStepChanged(CurStep: TSetupStep);
var
fileName : string;
begin
// Called at the end of setup
if CurStep = ssPostInstall then
begin
// create the directory and file name
fileName := ExpandConstant('{pf}\{#MyAppPublisher}\{#MyAppName}\c3deditor');
// log the operation
Log('Creating ' + fileName + '.bat');
// write a one line batch file to run the app
SaveStringToFile(fileName + '.bat',#34 + fileName + '.exe" -b %1' + #13#10, False);
end;
end;
 
Share this answer
 
Comments
Dave Kreskowiak 31-Oct-19 13:18pm    
Asked and answered much better than what you posted SEVEN YEARS AGO.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900