Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Was MyApp.exe started as a scheduled task?
Message
 
 
To
12/10/2001 08:03:36
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00567496
Message ID:
00567600
Views:
12
>Well the title pretty much says it:
>
>I'd like to determine if the VFP executeable MyApp.exe was started as a scheduled task or from a shortcut, command prompt, Explorer click or whatever.
>
>I guess the questions here are can do? and how to?
>
>TIA to those of you who'll help me out here.

There is no way to determine how your EXE was launched. Run, double-clicking from Explorer, task, etc. all look the same while inside the application.

One suggestion would be while in the application, test for the current user. Scheduled applications are usually executed using the SYSTEM account context, unless you specify INTERACTIVE when scheduling the task.

When you test for the user name, if it is SYSTEM then you know it was executed via the scheduler. You can use SYS(0) for this or the following snippet:
declare integer GetUserName in advapi32 string@, integer@
lcbuffer = replicate(chr(0),255)
lnbuflen = 255

if GetUserName(@lcbuffer, @lnbuflen) > 0 ;
   and upper(left(lcbuffer,lnbuflen)) = "SYSTEM" then
   * scheduled task
endif
HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Reply
Map
View

Click here to load this message in the networking platform