Browse
Tools
Categories

Using Windows Task Scheduler

Reference Number: AA-01084 Views: 7298 Last Updated: 05-03-2022 04:18 PM 0 Rating/ Voters

This article describes how to configure the Windows Task Scheduler to deliver a SiteAudit report.

Using Windows Task Scheduler to Generate Reports

This section describes how to schedule reports using the Windows Task Scheduler. Three files are required when creating a task to run a Hosted Client scheduled report. If scheduling reports for SiteAudit On-Site, then only two arguments are required. The following are samples of these arguments:

  1. The application file that is used to generate scheduled reports is located in the SiteAudit installation root folder:
    "C:\Program Files\Netaphor\SiteAudit\SiteAuditScheduledReports.exe"

  2. The .view file, which is the template created from a SiteAudit view. This file must contain the email recipient information and/or the archival information so that SiteAudit knows what to do with the report it generates. The .view file should be saved in a known location as the entire path and file name are needed when scheduling the task.
    "C:\Users\Public\Documents\Netaphor\SiteAudit\MyReports\Inventory.view"

  3. The keyfile that contains the information needed to access the hosted database for which the report is generated:
    "C:\Users\Public\Documents\Netaphor\SiteAudit\MyReports\sampledatabase.sakey"
Scheduled Task Parameters

  • Creating scheduled tasks for On-Site solutions requires items 1 & 2 above, whereas creating a scheduled task for Hosted deployments requires items 1, 2, & 3 above. 
  • The full path and file name is required for all files shown above. 
  • Quotes are required around the path and file name if any spaces exist.

The first step toward creating a scheduled report is to launch the Microsoft Windows Task Scheduler and create a new task. When a new task is created, the following dialog is shown.


Figure 1: Create Task dialog

Enter a Name for the task. This name is shown in the main Task Scheduler menu and should easily identify what the report is or what it contains. In this example, we are creating a monthly inventory report for CustomerX.

Enter a description that helps to identify the type of report that will be generated.

Select "Run with highest privileges."

Create a new trigger. The trigger identifies when or how frequently the report will be run. In this case, we want the report to be generated on the last day of each month.


Figure 2: New Trigger dialog

After defining the trigger, Task Scheduler must be told what task to run. This is done by creating a new Action. This is the most important aspect of creating the task as this is where the view file and key file are specified.   

In the Action drop-down, be sure that Start a program is selected. This should be selected by default.


Figure 3: Action dialog

In the Program/script text-box, enter the full path and file name for the SiteAuditScheduledReports.exe, which is located in the default root folder where SiteAudit was installed. This is typically:

  • C:\Program Files\Netaphor\SiteAudit

Remember to include quotations around the full path and file name when spaces exist. 

Next, it is necessary to enter the path and file name for the .view file. If creating a scheduled report for a Hosted Client database, including the -keyfile argument is required as well. The –viewfile and –keyfile arguments must precede the path and file name. For On-Site solutions, the -keyfile argument is not required and should not be entered.

Sample Argument for On-Site Solutions

  • -viewfile “C:\Users\Public\Documents\Netaphor\SiteAudit\MyReports\inventory.view” -culturename en-gb

Sample Arguments for Hosted Client Solutions

  • -viewfile “C:\Users\Public\Documents\Netaphor\SiteAudit\MyReports\inventory.view” –keyfile “C:\customers\keyfiles\customerX.sakey” -culturename en-bg

The task can then be saved and run to confirm that the expected report is generated and delivered to the correct recipients and/or archived to the file system.


Running Scheduled Task with Service Account

It may be desireable to run a scheduled task to generate a report whether or not a user is logged into the machine. In this case, select the radio button "Run whether user is logged in or not" and select the account that is used to run the task. This can be a service account or another user account. A password prompt appears when the task is saved or closed. Enter the password for the user and then, as long as the machine is turned on, the task will run even when no user is logged in.


If an error occurs that indicates that the password cannot be saved, then there may be a group policy applied on the machine that prevents saving the password. The group policy can be disabled following the steps below.

  • Open the Local Group Policy by typing SECPOL.MSC in the Windows search bar and selecting the application
  • Navigate to Security Settings > Local Policies > Security Options
  • Ensure the following is disabled: Network access: Do not allow storage of passwords and credentials