Subversion Repositories delphiutils

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

program bwd;

{

Batch-Working-Directory
Executes a batch script and set the working directory to
the batch script's directory.

}

uses
  ShellAPI;

{$R *.res}

var
  i: integer;
  params: string;

begin
  if ParamCount() < 1 then
  begin
    WriteLn('Batch-Working-Directory');
    WriteLn('Executes a file and set the working directory to the file''s directory');
    WriteLn('');
    WriteLn('Syntax: bwd.exe application [params]');
  end
  else
  begin
    params := '';
    for i := 2 to ParamCount() - 1 do
    begin
      params := ParamStr(i);
    end;

    // ToDo: In Konsole einbetten?
    ShellExecute(0, 'open', ParamStr(1), PChar(params), ExtractFilePath(ParamStr(1)), SW_NORMAL);
  end;
end.