so you are launching a new process "plink" that you want to control by writing commands to its input.
to do so, you should not use printf: printf outputs to the standard output. here you need to write to the standard input of the new process. the procedure is described in the msdn article i linked above.