OLD | NEW |
| (Empty) |
1 // Copyright 2008-2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 | |
16 #ifndef OMAHA_COMMON_SCHEDULED_TASK_UTILS_INTERNAL_H_ | |
17 #define OMAHA_COMMON_SCHEDULED_TASK_UTILS_INTERNAL_H_ | |
18 | |
19 #include <windows.h> | |
20 #include <taskschd.h> | |
21 | |
22 namespace omaha { | |
23 | |
24 namespace scheduled_task_utils { | |
25 | |
26 namespace internal { | |
27 | |
28 // Gets the current name, say "GoogleUpdateTaskMachineCore", of the | |
29 // GoogleUpdateCore scheduled task, either from the registry, or a default | |
30 // value if there is no registration. | |
31 CString GetCurrentTaskNameCore(bool is_machine); | |
32 | |
33 // Creates a unique name, say "GoogleUpdateTaskMachineCore1c9b3d6baf90df3", of | |
34 // the GoogleUpdateCore scheduled task, and stores it in the registry. | |
35 // Subsequent invocations of GetCurrentTaskNameCore() will return this new | |
36 // value. | |
37 HRESULT CreateAndSetVersionedTaskNameCoreInRegistry(bool machine); | |
38 | |
39 // Gets the current name, say "GoogleUpdateTaskMachineUA", of the | |
40 // GoogleUpdateUA scheduled task, either from the registry, or a default value | |
41 // if there is no registration. | |
42 CString GetCurrentTaskNameUA(bool is_machine); | |
43 | |
44 // Creates a unique name, say "GoogleUpdateTaskMachineUA1c9b3d6baf90df3", of | |
45 // the GoogleUpdateUA scheduled task, and stores it in the registry. | |
46 // Subsequent invocations of GetCurrentTaskNameUA() will return this new | |
47 // value. | |
48 HRESULT CreateAndSetVersionedTaskNameUAInRegistry(bool machine); | |
49 | |
50 // Installs a scheduled task. The task will run as either as SYSTEM or the | |
51 // current user. The task will be triggered at each user logon, and/or | |
52 // fixed intervals. | |
53 HRESULT InstallScheduledTask(const TCHAR* task_name, | |
54 const TCHAR* task_path, | |
55 const TCHAR* task_parameters, | |
56 const TCHAR* task_comment, | |
57 bool is_machine, | |
58 bool create_logon_trigger, | |
59 bool create_daily_trigger, | |
60 bool create_hourly_trigger); | |
61 | |
62 // Deletes a scheduled task. | |
63 HRESULT UninstallScheduledTask(const TCHAR* task_name); | |
64 | |
65 // Deletes all scheduled tasks with the given prefix. | |
66 HRESULT UninstallScheduledTasks(const TCHAR* task_prefix); | |
67 | |
68 // Runs a scheduled task immediately. | |
69 HRESULT StartScheduledTask(const TCHAR* task_name); | |
70 | |
71 // Returns true if the scheduled task exists. | |
72 bool IsInstalledScheduledTask(const TCHAR* task_name); | |
73 | |
74 // Returns the priority at which the scheduled task process will run. Returns 0 | |
75 // on failure. | |
76 DWORD GetScheduledTaskPriority(const TCHAR* task_name); | |
77 | |
78 // Returns true if the scheduled task ever ran. | |
79 bool HasScheduledTaskEverRun(const TCHAR* task_name); | |
80 | |
81 // Returns a status code on success. List of status codes at | |
82 // http://msdn2.microsoft.com/en-us/library/aa381263.aspx | |
83 HRESULT GetScheduledTaskStatus(const TCHAR* task_name); | |
84 | |
85 // Stops the task if it is already running. | |
86 HRESULT StopScheduledTask(const TCHAR* task_name); | |
87 | |
88 // Waits for the task to change its status to the specified status value and | |
89 // returns the status of the task. If the status did not change within the | |
90 // time, it returns the status of the task at the end of the wait. | |
91 HRESULT WaitForTaskStatus(const TCHAR* task_name, HRESULT status, int time_ms); | |
92 | |
93 namespace v2 { | |
94 | |
95 // Task Scheduler 2.0 API helpers. | |
96 bool IsTaskScheduler2APIAvailable(); | |
97 HRESULT GetRegisteredTask(const TCHAR* task_name, IRegisteredTask** task); | |
98 bool IsScheduledTaskRunning(const TCHAR* task_name); | |
99 HRESULT StartScheduledTask(const TCHAR* task_name); | |
100 HRESULT StopScheduledTask(const TCHAR* task_name); | |
101 | |
102 } // namespace v2 | |
103 | |
104 } // namespace internal | |
105 | |
106 } // namespace scheduled_task_utils | |
107 | |
108 } // namespace omaha | |
109 | |
110 #endif // OMAHA_COMMON_SCHEDULED_TASK_UTILS_INTERNAL_H_ | |
111 | |
OLD | NEW |