How to send input to cmd when cmd is running as administrator?
问题 I created an application that sends keyboard input to cmd.exe . This works when running cmd as a normal user but fails when cmd is run as Administrator. This is my code: Var Wnd:hwnd; begin wnd:=FindWindow('ConsoleWindowClass',0); if wnd <> 0 then begin setforegroundWindow(wnd); keybd_event(Ord('A'),0,0,0); end; end; Notice that ConsoleWindowClass is the class name of cmd . How can I send input to cmd when cmd is running as administrator? 回答1: How can I type with this code inside cmd when cmd