How to use LPRun8.exe in background?
I try to use windows Task Scheduler to trigger LPRun8.exe to run winform while log on.
Code
void Main() { System.Windows.Forms.Application.Run(new MyForm()); } public class MyForm : System.Windows.Forms.Form { public MyForm() { this.Text = "WinForms in LINQPad"; this.Size = new System.Drawing.Size(400, 300); var label = new System.Windows.Forms.Label() { Text = "This is a label", Location = new System.Drawing.Point(10, 10) }; this.Controls.Add(label); } }
Windows Task Scheduler
Result Photo
But it will keep showing a LPRun8.exe window untill I close the Winforms.
Any way to make the LPRun8 window run in background?
Comments
You can create standalone WinForms application and run it.
Alternatively, you can call the Win32 API
FreeConsole()
to unallocate the console assigned to the process. LPRun8-x64.exe will show the console while it's starting up, but as soon as it gets to and runs your code, you can call FreeConsole to have the system unallocate it and close it. The process (and form) will continue running like you expect. If you're okay with that brief flicker, then you're just a P/Invoke call away.