Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Was MyApp.exe started as a scheduled task?
Message
 
 
À
12/10/2001 08:03:36
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00567496
Message ID:
00567600
Vues:
14
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform