Check for scheduled task example for inno setup
When searching the best way to check for a scheduled task in google search with inno setup there was no real information or examples could be found so i am sharing my code, Hopefully this example will help someone.
Simply place the code example in the examples folder of inno setup installation directory.
- If the task has no folder just use the task name 'TASKNAME'
- If the task is in a folder use the folder name then backslash task name 'FOLDER\TASKNAME'
if (TaskExist('TASKNAME')) then
begin
msgbox('Your task was found!', mbInformation, MB_OK)
end
if (TaskExist('FOLDER\TASKNAME')) then
begin
msgbox('Your task was found!', mbInformation, MB_OK)
end
if (TaskExist('FOLDER\FOLDER\FOLDER\TASKNAME')) then
begin
msgbox('Your task was found!', mbInformation, MB_OK)
end
You can use ExpandConstant()
in this field.
if (TaskExist(ExpandConstant ('{#MyAppName}'))) then
begin
msgbox('Your task was found!', mbInformation, MB_OK)
end
if (TaskExist(ExpandConstant ('{#MyAppName}{#MyUserInput}'))) then
begin
msgbox('Your task was found!', mbInformation, MB_OK)
end
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this example code, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
THE EXAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.