Recent

Author Topic: RunCommand  (Read 4726 times)

Emerson

  • New Member
  • *
  • Posts: 37
RunCommand
« on: July 29, 2021, 12:24:29 am »
Hi!
   
    I have a problem when executing a command with RunCommand.
    When running the same, a black prompt screen appears and I would like to hide.
   
    Can someone help me?

RunCommand('cmd.exe', ['/c', v_comando], v_resultado_da_exec_shell);

sstvmaster

  • Sr. Member
  • ****
  • Posts: 299
« Last Edit: July 29, 2021, 10:50:09 am by sstvmaster »
greetings Maik

Windows 10,
- Lazarus 2.2.6 (stable) + fpc 3.2.2 (stable)
- Lazarus 2.2.7 (fixes) + fpc 3.3.1 (main/trunk)

BobDog

  • Sr. Member
  • ****
  • Posts: 394
Re: RunCommand
« Reply #2 on: July 29, 2021, 12:53:04 pm »

For windows to access the command shell you can do:
Code: Pascal  [Select][+][-]
  1.   program shell;
  2.  
  3. function  system(s:pchar):integer ; cdecl external 'msvcrt.dll' name 'system';
  4. function  wsystem(s:widestring):integer ; cdecl external 'msvcrt.dll' name '_wsystem';
  5.  
  6.  
  7. procedure speak(text:ansistring);
  8. var x:ansistring;
  9. begin
  10.      x:='mshta vbscript:Execute("CreateObject(""SAPI.SpVoice"").Speak(""'+text+'"")(window.close)")';
  11.       system(pchar(x)) ;
  12.   end;
  13.  
  14.  
  15. begin
  16. system('help');
  17. speak('thank you, goodbye');
  18. readln;
  19. end.
and get all those old dos commands or powershell commands
wsystem is optional for widestrings.

sstvmaster

  • Sr. Member
  • ****
  • Posts: 299
Re: RunCommand
« Reply #3 on: July 29, 2021, 02:44:49 pm »
@Emerson

Code: Pascal  [Select][+][-]
  1. RunCommand('cmd.exe', ['/c', v_comando], v_resultado_da_exec_shell, [], swoHIDE);
greetings Maik

Windows 10,
- Lazarus 2.2.6 (stable) + fpc 3.2.2 (stable)
- Lazarus 2.2.7 (fixes) + fpc 3.3.1 (main/trunk)

Emerson

  • New Member
  • *
  • Posts: 37
Re: RunCommand
« Reply #4 on: August 02, 2021, 02:04:51 pm »
Hi! The answer from the sstv master friend was successful. Thanks everyone for responding.

 

TinyPortal © 2005-2018