The question is: without interrupting the execution of the program, how to obtain the visibility of the main screen when the procedure started before the user login?
I
think the answer is that you can't. But you can work around it...
I have also used Windows Task Scheduler to start programs before user log in and have faced the same problem. I have overcome it in two different ways which suit different circumstances:
Option 1:
Split the program in two, creating a non-UI app to do the work and a UI app which just displays what the non-UI app is doing/has done. You can then use Task Scheduler to start the non-ui app before the user logs in, and then only fire up the UI 'front-end' app when Windows log-in occurs.
Option 2:
Create a mechanism in your app which checks on app start if an instance of the app is already running. If it is you can use jShell ('taskkill') to forcibly close it, or (my preferred method) add handling of UDP messages in your app and send a 'close' message to the 'hidden' app so that you can close it down in a more controlled way than 'taskkill' allows.
With either of these app closing options, use Task Scheduler to start the app before Windows user login and also have it auto-start after Windows user log in.
When Windows log-in occurs the new instance of the app starts up, closes the 'hidden' one and then finishes starting up showing the main form which was previously hidden.
There are probably other routes you could take as well, but these are the two that I've used with some success.