Subversion Repositories delphiutils

Rev

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

  1. program bwd;
  2.  
  3. {
  4.  
  5. Batch-Working-Directory
  6. Executes a batch script and set the working directory to
  7. the batch script's directory.
  8.  
  9. }
  10.  
  11. uses
  12.   ShellAPI, SysUtils, Windows;
  13.  
  14. {$R *.res}
  15.  
  16. var
  17.   i: integer;
  18.   params: string;
  19.  
  20. begin
  21.   if ParamCount() < 1 then
  22.   begin
  23.     WriteLn('Batch-Working-Directory');
  24.     WriteLn('Executes a file and set the working directory to the file''s directory');
  25.     WriteLn('');
  26.     WriteLn('Syntax: bwd.exe application [params]');
  27.   end
  28.   else
  29.   begin
  30.     params := '';
  31.     for i := 2 to ParamCount() - 1 do
  32.     begin
  33.       params := ParamStr(i);
  34.     end;
  35.  
  36.     // ToDo: In Konsole einbetten?
  37.     ShellExecute(0, 'open', PChar(ParamStr(1)), PChar(params), PChar(ExtractFilePath(ParamStr(1))), SW_NORMAL);
  38.   end;
  39. end.
  40.