TProcess strips quotes from command line parameters? lazarus / 21-General ---------------------------------------------------------------------- Superdisk · 2021-06-07 01:01 I'm trying to call a process using TProcess, like so: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...Proc.Parameters.Add('-DSomething="Something else"');Proc.Execute; To check that the parameter gets passed correctly, I wrote a small program which just dumps out its arguments to a file: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program bogus; uses sysutils; var        I: Integer;        F: TextFile;begin        Randomize;        Assign(F, IntToStr(Random(100000))+'.txt');      Rewrite(F);        for I := 0 to ParamCount do                Writeln(F,ParamStr(I));        Close(F);end. But what I'm seeing is this: -DSomething=Something else rather than -DSomething="Something else" like I would expect. The program that I'm invoking needs these quotes to work, and I'm not sure how to tell TProcess to leave them there. ---------------------------------------------------------------------- Aidex · 2021-06-07 05:02 Hi! Under Windows this is the usual notation: "-DSomething=Something else" The quotation marks enclose the entire expression. ---------------------------------------------------------------------- Superdisk · 2021-06-07 05:06 Hi, thanks for the reply. Unfortunately, I really do need the literal quotes to be passed into the subprocess as part of the argument-- the program itself expects them to be there. Any idea how I can get TProcess to preserve the double quotes without discarding them? ---------------------------------------------------------------------- Aidex · 2021-06-07 05:21 Test these: '-DSomething="Something else"' "-DSomething=^"Something else^"" "-DSomething=""Something else""" PS: Maybe test it at the command line first, and only if it works there, with TProcess. ---------------------------------------------------------------------- Jurassic Pork · 2021-06-07 08:58 hello, what is wrong ? with this code : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);var Proc:TProcess;begin    try   Proc := TProcess.Create(nil);   Proc.Executable := 'cmd.exe';   Proc.Parameters.Add('/c');   Proc.Parameters.Add('echo');   Proc.Parameters.Add('-DSomething="Something else"');   Proc.Execute();   finally ;     Proc.Free;   end; end;           i get what you can see in attachment Friendly, J.P ---------------------------------------------------------------------- Martin_fr · 2021-06-07 09:18 I am not sure. This may actually the parsing of "GetCommandLineW" in the called process. In the process, that needs the quotes, try calling GetCommandLineW directly. (on win) argv is already processed by some code in the rtl. ---------------------------------------------------------------------- marcov · 2021-06-07 10:03 Fixes branch and trunk might differ in behaviour: r45037 | yury | 2020-04-23 14:38:42 +0200 (Thu, 23 Apr 2020) | 4 lines Changed paths:    M /trunk/rtl/inc/system.inc    M /trunk/rtl/inc/uuchar.pp    M /trunk/rtl/objpas/objpas.pp    M /trunk/rtl/win/sysos.inc    M /trunk/rtl/win/syswin.inc    M /trunk/rtl/win/syswinh.inc    M /trunk/rtl/win32/system.pp    M /trunk/rtl/win64/system.pp * Windows: Reworked handling of command line arguments to properly support Unicode:   - Use the CommandLineToArgvW API function to parse the Unicode command line (we can use it since Win9x is not supported anymore).   - Implemented non-public functions ParamStrA and ParamStrU which are exposed in the objpas and uuchar units to provide correct AnsiString and UnicodeString versions of ParamStr().   - The cleanup code is moved from InternalExit to the finalization section of the System unit. --- r45227 | yury | 2020-05-02 20:19:26 +0200 (Sat, 02 May 2020) | 3 lines Changed paths:    M /trunk/rtl/win/sysos.inc    M /trunk/rtl/win/syswin.inc * Windows: Do not use CommandLineToArgvW for parsing command line parameters, because it treats \" as an escape sequence for the double quote.   - Implemented parsing of the command line which is backward compatible.   - Do not use GetCommandLineA.