Running from Other Applications


You can run Stonefield Query from the Windows Command Prompt, the Windows Run dialog, a batch file, or another application so you don't have to find its icon on the Windows Desktop or in the Start menu and so you can have it automatically log in or run a particular report. To do so, execute:

directory\SFQuery.exe

In place of directory, enter the directory where Stonefield Query is installed. If there is a space in the directory, put quotes around this command. For example:

"C:\Program Files\Stonefield Query\SFQuery.exe"

If the Stonefield Query configuration files aren't located in the same directory as SFQUERY.EXE and Stonefield Query hasn't been run before on this computer, add "ini=directory" to the command line. In place of directory, enter the directory where the configuration files are located. Again, if there are any spaces in the directory, surround the entire parameter with quotes.

To automatically log into Stonefield Query, add "user=username" and "password=userpassword" to the command line. In place of username and userpassword, enter the user name and password. Here's an example (although this example is displayed on several lines for formatting purposes, enter everything on one line):

"C:\Program Files\Stonefield Query\SFQuery.exe"
  user=etaylor password=diamond

If you want Stonefield Query to automatically print a particular report, add "report=reportname" to the command line. In place of reportname, enter the name of the report. Put quotes around the entire parameter (for example, "report=My Activity Report") if there are any spaces in the report name. If you want to run more than one report, specify "report1=reportname1", "report2=reportname2", and so forth.

Stonefield Query can also accept several other parameters that tell it how to behave:

If the command line becomes too long (Stonefield Query only accepts 15 parameters; more than that cause an error) or you'd rather put the parameters into a file for more flexibility (it's probably easier to change the contents of a file than to change how Stonefield Query is called), specify the name of the file containing the parameters by adding "parameters=filename", where filename is the name of the file containing the parameters. The file must contain the same format of parameters passed on the command line, with each parameter on a separate line, except you don't need quotes even if there are spaces in the names. Here's an example of such a file that outputs the Activity Report for March 2001 to an Excel document named C:\Temp\My Spreadsheet.xls and the History Report to a PDF file named C:\Temp\MyPDF.pdf, and then exits Stonefield Query:

report1=Activity Report
filename1=C:\Temp\My Spreadsheet.xls
value1=2001-03-01,2001-03-31
report2=History Report
filename2=C:\Temp\MyPDF.pdf
user=etaylor
password=diamond

Here are some examples of these parameters (although these examples are displayed on several lines for formatting purposes, enter everything on one line):

"C:\Program Files\Stonefield Query\SFQuery.exe"
   "report=Activity Report" user=etaylor password=diamond

Prints the Activity Report to the printer.

"C:\Program Files\Stonefield Query\SFQuery.exe"
  "report=Activity Report" preview
  user=etaylor password=diamond

Displays the Activity Report in the preview window.

"C:\Program Files\Stonefield Query\SFQuery.exe"
  "report=Activity Report" preview
  value=2001-03-01,2001-03-31
  user=etaylor password=diamond

Displays the Activity Report in the preview window for records between March 31, 2001 and March 31, 2001 (assuming an ask at runtime condition on the date range).

"C:\Program Files\Stonefield Query\SFQuery.exe"
  "report=Activity Report" filename=C:\Temp\MySpreadsheet.xls
  user=etaylor password=diamond

Outputs the Activity Report to an Excel document named C:\Temp\MySpreadsheet.xls and brings up Excel once the document is ready.

"C:\Program Files\Stonefield Query\SFQuery.exe"
  "report=Activity Report" filename=C:\Temp\MySpreadsheet.xls
  noshow user=etaylor password=diamond

Outputs the Activity Report to an Excel document named C:\Temp\MySpreadsheet.xls but doesn't bring up Excel.

"C:\Program Files\Stonefield Query\SFQuery.exe"
  "report=Activity Report" preview exit
  user=etaylor password=diamond

Displays the Activity Report in the preview window and exits Stonefield Query once the preview window is closed.

"C:\Program Files\Stonefield Query\SFQuery.exe"
  "report=Activity Report" "filename=C:\Temp\My Spreadsheet.xls"
  exit user=etaylor password=diamond

Outputs the Activity Report to an Excel document named C:\Temp\My Spreadsheet.xls, exits Stonefield Query, and opens the document in Excel.

"C:\Program Files\Stonefield Query\SFQuery.exe"
  "report=Activity Report" mailto=myboss@mycompany.com
  "subject=This Week's Activity Report"
  "body=Here's the activity report for this week."
  exit user=etaylor password=diamond

Emails the Activity Report as a PDF file attached to a message sent to myboss@mycompany.com.