[Solved] Elevated running with XCOPY.exe lazarus / 34-Windows ---------------------------------------------------------------------- AlexTP · 2024-04-22 05:19 Here is the primitive demo which calls RunElevated (in included unit) to copy project1.ico to system folder "C:\Windows\System32\drivers\etc". It shows the elevation OS window, I press Yes, XCOPY asks for 'F' or 'D' key, I press F, and nothing. File is not copied. What can I do wrong? It is needed for the CudaText project to overwrite 'hosts' file when user tries to save it. 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 unit proc_windows_elevated; {$mode ObjFPC}{$H+} interface function RunElevated(const AProgram, AParameters: UnicodeString): boolean; implementation uses  Windows, ShellAPI, SysUtils, Classes, Forms; function RunElevated(const AProgram, AParameters: UnicodeString): boolean;var  sei: TShellExecuteInfoW;begin  FillChar(sei, SizeOf(sei), 0);  sei.cbSize := SizeOf(sei);  sei.fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_UNICODE;  sei.Wnd := Application.MainForm.Handle;  sei.lpVerb := 'runas';  sei.lpFile := PWideChar(AProgram);  sei.lpParameters := PWideChar(AParameters);  sei.nShow := SW_SHOW;   Result := ShellExecuteExW(@sei);  if Result then  begin    WaitForSingleObject(sei.hProcess, INFINITE);    CloseHandle(sei.hProcess);  end  else    Application.MessageBox(      PChar(Format('ShellExecuteExW failed: %d', [GetLastError])),      'CudaText');end; end. ---------------------------------------------------------------------- AlexTP · 2024-04-22 07:40 Found the reason. I used Win32 32-bit target. For C:\Windows paths, I must use 64-bit target.