The easiest option would be to have a command line switch. Setup your scheduled task to launch your program like so:
myProgram.exe /noui
Then just use
Environment.GetCommandLineArgs() to check for the flag. If it exists, don't show your UI.
This way, when the user just starts your program normally, it'll run with a UI. When you schedule the task, as long as you put in the flag, it won't show the UI.
A more elaborate, but potentially nicer approach, would be to make 2 versions of your program. Move all of your logic to a library project (DLL), and just have a exe that wraps the DLL in a UI, and an exe that wraps it in a console app. Use the console app for your scheduled task.
Reed Copsey, Jr. -
http://reedcopsey.com