Recent

Author Topic: [SOLVED] TProcess : Failed to execute : 193  (Read 6700 times)

Gizmo

  • Hero Member
  • *****
  • Posts: 831
[SOLVED] TProcess : Failed to execute : 193
« on: June 11, 2015, 05:35:19 pm »
Lazarus 1.4.0, FPC 2.6.0, Windows 7 Pro, 64-bit.

The following simple right click procedure should launch the Windows Disk Manager from my own program on all Windows platforms, but so far I have not got beyond testing on Windows 7 Pro. It returns

Quote
Project raised exception class 'EProcess' with message
Failed to execute : 193
At address 4D6636

Code: [Select]
procedure TfrmYaffi.menShowDiskManagerClick(Sender: TObject);
var
ProcDiskManager : TProcess;
begin
  try
    ProcDiskManager            := TProcess.Create(nil);
    ProcDiskManager.Executable := 'C:\Windows\System32\diskmgmt.msc'; // the file is there, I am administror, my program runs as administrator, and if I paste that into terminal, it launches
    ProcDiskManager.Options    := [poWaitOnExit, poUsePipes];
    ProcDiskManager.Execute;
  finally
    ProcDiskManager.Free;
  end;
end;

I have no spaces in my project path, I tried copying it all to c:\temp too, and I tried running just the exe externally of Lazarus. Results are always the same.

Any ideas? Ta
« Last Edit: June 11, 2015, 05:55:21 pm by Gizmo »

paweld

  • Hero Member
  • *****
  • Posts: 1568
Re: TProcess : Failed to execute : 193
« Reply #1 on: June 11, 2015, 05:49:41 pm »
*.msc is not executable file, only file associated with mmc.exe. You must exec like this:
Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var
  ProcDiskManager : TProcess;
begin
  try
    ProcDiskManager            := TProcess.Create(nil);
    ProcDiskManager.Executable := 'mmc.exe';
    ProcDiskManager.Parameters.Add:='C:\Windows\System32\diskmgmt.msc';
    ProcDiskManager.Options    := [poWaitOnExit, poUsePipes];
    ProcDiskManager.Execute;
  finally
    ProcDiskManager.Free;
  end;
end;
Best regards / Pozdrawiam
paweld

Gizmo

  • Hero Member
  • *****
  • Posts: 831
Re: TProcess : Failed to execute : 193
« Reply #2 on: June 11, 2015, 05:55:10 pm »
Well don't I now feel like an as**!

Many thanks for pointing that out. I thought I was going insane.

 

TinyPortal © 2005-2018