Jump to content

tgbs

Members
  • Content Count

    109
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by tgbs


  1. function RunProcess(CommandLine: String; Var ErrMessage : String; WaitForProcess : Boolean; CreationFlags : Word): Boolean;
    Var
      ResultCode : LongWord;
      StartInfo: TStartUpInfo;
      ProcInfo: TProcessInformation;
    begin
      Result := False;
      ResultCode := 1;
    
      FillChar(StartInfo, SizeOf(TStartUpInfo), #0);
      FillChar(ProcInfo, SizeOf(TProcessInformation), #0);
      StartInfo.cb := SizeOf(TStartUpInfo);
      StartInfo.dwFlags := STARTF_USESHOWWINDOW;
     // StartInfo.wShowWindow := SW_SHOWMINIMIZED;
    
      UniqueString(CommandLine);
    try
      try
        IF NOT CreateProcess(nil, 
                       PChar(CommandLine),
                       nil,               
                       nil,               
                       FALSE,             
                       CreationFlags,     
                       nil,               
                       nil,               
                       StartInfo,         
                       ProcInfo)          
           THEN BEGIN
             ErrMessage := SysErrorMessage(GetLastError);
             Exit;
           END;
      except
        on e : exception do
          begin
            ErrMessage := e.Message + #13#10 + SysErrorMessage(GetLastError);
            Exit;
          end;
      end;
    
      if not WaitForProcess then ResultCode := 0
        else begin
          WaitForSingleObject(ProcInfo.hProcess, INFINITE);
          GetExitCodeProcess(ProcInfo.hProcess, ResultCode);
        end;
    finally
      Result := (ResultCode = 0);
      //--------
      CloseHandle(ProcInfo.hProcess);
      CloseHandle(ProcInfo.hThread);
    end;
    end;

    Set CommandLine to somehing like  @corneliusdavid comment

    • Like 1

  2. You can write your extension (script) to a Cockpit and then perform remotely. Extensions can be written on JavaScript. Can be called through something like this
    curl -u 'Username: Password' -x Post \
     -d '{"Script": "/Path/to/your-script.sh", "args": ["arg1", "arg2"]}' \
     https: // <Server-IP>: 9090/My-Scripts/Execute
    I think there was also a ready -made feature to access Shell, but I don't remember what it is. Since curl can be used, I see no reason for not writing the Delphi program. There are documentation for existing and new extensions.

     

    Edit: A program can be written that performs something like this
    ssh user@Server-IP> 'sudo myscript.sh'
    The user must have sudo rights and be able to enforce it without a password. This is configured on the server. I think there are a lot of SSH access libraries with keys, not password

     


  3. 2 hours ago, Uwe Raabe said:

    It is even possible at design time. Setting an empty name to a component will remove the corresponding field in the class. It is often used with TLabel instances that only exist to display some static text, but won't be accessed in the code. It reduces code cluttering a bit.

    This can be a problem in a multilingual project


  4. On 9/14/2024 at 6:21 PM, Clément said:

    I just accessed the machine without VM and the code editor doesn't blink.
    Is there any special new settings for RDP access?

    My colleagues and I planned to upgrade from 12.1 to 12.2 next week. Most of the time we access Delphi in the office through VPN and RDP. Most PCs with Delphi 12.1 installed are real, but there are also VMs.
    I didn't understand when the problem occurs

×