Have you tested this simple way of doing it below program test; {$mode objfpc} {$H+} uses windows; begin ShellExecute(0 , 'open', 'notepad', nil, nil, SW_SHOWNORMAL) ; ShellExecute(0 , 'open', 'notepad', nil, nil, SW_HIDE) ; end. The cmd /k may not even be needed... and it may not even work the way I showed in the previous examples in my emails.