I tries a solution to run application with admin from wiki, but this didn't create file either (by the way, creating file isn't my end-goal, it just a way to see if it work). Here is code:
function RunAsAdmin(const Handle: Hwnd; const Path, Params: string): Boolean;
var
sei: TShellExecuteInfoA;
begin
FillChar(sei, SizeOf(sei), 0);
sei.cbSize := SizeOf(sei);
sei.Wnd := Handle;
sei.fMask := SEE_MASK_FLAG_DDEWAIT or SEE_MASK_FLAG_NO_UI;
sei.lpVerb := 'runas';
sei.lpFile := PAnsiChar(Path);
sei.lpParameters := PAnsiChar(Params);
sei.nShow := SW_SHOWNORMAL;
Result := ShellExecuteExA(@sei);
end;
RunAsAdmin(0, 'cmd.exe echo "FirstLine" > "C:\Windows\textfile.txt"', '');
But file does not create?
How to run cmd command with admin from program? Thank.