Forum > Windows

Having trouble with TProcess and RunCommand on Windows

<< < (2/2)

trev:
Check where it's looking for the unit - turn on all messages (Lazarus > Project > Project Options > Compiler options > Verbosity - [ ] Show everything) and copy "All/Original Messages" from messages window to the clipboard at end of compilation. It will show you where it is looking for the Process unit and not finding it.

mosquito:
Just an idea, if the external executable is not on the same level of the file system, try using the executable's full path.

rail5:
Thanks everybody for replying, and happy holidays by the way

Well, the logs show that the compiler isn't having trouble finding the Process unit (+ Library + Object), so the "unit not found" bug is just isolated in the Source viewer in Lazarus


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---[1.010] (10000) Unitsearch: /usr/lib/fpc/3.2.0/units/x86_64-win64/fcl-process/process.ppu[1.010] Searching file /usr/lib/fpc/3.2.0/units/x86_64-win64/fcl-process/process.ppu... found[1.010] (10001) PPU Loading /usr/lib/fpc/3.2.0/units/x86_64-win64/fcl-process/process.ppu[1.010] (PROCESS)  (10002) PPU Name: /usr/lib/fpc/3.2.0/units/x86_64-win64/fcl-process/process.ppu[1.010] (PROCESS)  (10011) PPU Source: process.pp not available[1.010] (PROCESS)  (10011) PPU Source: processbody.inc not available[1.010] (PROCESS)  (10011) PPU Source: process.inc not available

Which brings me back to square 1 -- RunCommand seems to work on Linux when:
1. provided with a TStringArray of parameters
& 2. provided with an "array literal" so to speak
(as in RunCommand('liesel', SomeTStringArray, ReturnString) vs. RunCommand('liesel', ['-h', '-q', '-c'], ReturnString) for example)

Where on Windows, RunCommand only seems to work when provided with an "array literal,"

+ the TProcess fails (again only on Windows) and I can't tell why (with Parameters.Add() and then Execute). (I also tried with TProcess.CommandLine just to check, and that fails as well)


Is there maybe a problem on Windows just with programmatically determining those parameters as variables instead of being statically-fixed parameters (having the parameters determined at runtime instead of compile time)? The idea is for the user to select parameters from the GUI and then execute

If that's it, is there a way to force the compiler to recognize that a particular variable will only be set at runtime rather than compile time?

marcov:
I use runcommand daily, so it should be something with your setup.

Could you please make a complete minimal console application to give us something to test? Try to enable Delphi mode.

Try also to add the full path to the exe name(e.g. c:\a\b\liesel), maybe in your application the working directory is not what you think it is.

Navigation

[0] Message Index

[*] Previous page

Go to full version