Is there any way to find out, if an console-application (VB.net) was started by a user or the windows scheduler.
There´s a very similar thread, but no result: http://www.44342.com/visual-basic-f948-t16091-p1.htm
Is there any way to find out, if an console-application (VB.net) was started by a user or the windows scheduler.
There´s a very similar thread, but no result: http://www.44342.com/visual-basic-f948-t16091-p1.htm
I don't know what you are trying to achieve but wouldn't it be easiest to launch the application with some argument when running as a scheduled task?
If you don't want to use argument you can base the detection on information about parent process. E.g. name of the parent process will be 'svchost' when running from scheduler.
if(System.Diagnostics.Process.GetCurrentProcess().Parent().ProcessName == "svchost")
{
// Run once
}
else
{
// Loop
}