Recent

Author Topic: RunCommand  (Read 3715 times)

Emerson

  • New Member
  • *
  • Posts: 31
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: 259
« Last Edit: July 29, 2021, 10:50:09 am by sstvmaster »
Windows 10 (64 bit)
Lazarus: 2.0.12 / Trunk x32

BobDog

  • Full Member
  • ***
  • Posts: 127
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: 259
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);
Windows 10 (64 bit)
Lazarus: 2.0.12 / Trunk x32

Emerson

  • New Member
  • *
  • Posts: 31
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