A scheduled batch file is not executed

Applies to
ApexSQL Diff, ApexSQL Log

A batch file for executing ApexSQL application tasks works when run manually, but when scheduled using Windows Scheduler, nothing happens and no warning messages are shown

A batch file for executing an ApexSQL application task that creates an output file is created. For example:

SET OutputHTML=Differences.html

"C:\Program Files\ApexSQL\ApexSQLDiff2010\ApexSQLDiff.com"
/pf:D\:ApexSQL\forumc\ustomers\1634\DevToQA.axds /ot:Html /of:%OutputHTML% /f

When run manually from Windows Explorer, logged as a member of the Windows administrators group, the Differences.html file is created
But, when a Windows Task is created to execute the batch file, nothing happens and the Differences.html is not created

The reason for this issue is that the default Windows (Vista, Windows 7) user doesn’t have write access to the C:\Windows\System32 folder when UAC is turned on. As the location of the file to be created is not specified, it is created in the Windows\System32 folder

There are two solutions for this issue:

  • Run the scheduled task as an Administrator
    1. Open the Task Properties dialog
    2. Check the ‘Run with highest privileges’ option
  • Save the Differences.html file in a folder where the user has write privileges

In the batch file, instead of:
SET OutputHTML=Differences.html

Use the following code:
SET OutputHTML="D:Differences.html"

or provide any other local path where the Windows user has full privileges
To see the messages that are suppressed by default, add the /v switch to the batch file command

About ApexSQL
ApexSQL is a leading provider of SQL Server tools for database recovery, database auditing, database comparison, documentation as well as SQL Server Management Studio and Visual Studio add-ins for SQL code refactoring, code completion and database source control. We strive to ensure that every one of our tools is standard-defining product in its class, from feature set, to performance, interface and quality.

Last updated
April 7, 2013