Solution ID: 100006301 Title: Running SPSS Command Syntax from the Command Line or Batch File Description: Q. How can I tell SPSS 8.0 for Windows to run a command syntax file from a DOS command line? Batch (.BAT) file? NT Scheduler command? A. The command is simply runsyntx syntax.sps It will open the file "syntax.sps" in a command syntax window, and run the contents. If SPSS is not running, it will not become visible until the processor has finished. Note that this uses a program named "Runsyntx.exe", which is in the SPSS 8.0 for Windows directory. You may need to supply complete path names in double quotes to the .sps file, the .exe file, or to both, depending on the current directory and the locations of the files, for example: runsyntx "c:\\spss work\\syntax.sps" "c:\\program files\\spss\\runsyntx.exe" "c:\\program files\\spss\\syntx.sps" In a batch file, you may invoke Runsyntx more than once. Control will return to the batch as soon as the window opens, but before the results have been generated. The results should be generated in the order requested. Saving and printing output may be accomplished by using the SCRIPT command to run a suitable script. This is discussed in a separate technical note. Runsyntx will leave the command syntax window open. There is a script "CloseAllSyntaxWindows.sbs"at the end of this note, which will close all open command syntax windows. One can add SCRIPT "CloseAllSyntaxDocs.sbs". to a command syntax file to trigger it. The easiest thing to do in a batch file may be to save the SCRIPT command above to a command syntax file, and use Runsyntx to execute it. If things go wrong, please check the tasklist. You may see multiple copies of Runsyntx queued (if you invoked it more than once). If SPSS is not responding, you may need to use End Task to terminate each instance of Runsyntx. If you see OLE Automation error messages from Runsyntx, or if your results never appear, SPSS may not be responding. If SPSS is not visible, check the task list to see if SPSS for Windows and/or SPSSW are present; you may need to use End Task to terminate them. The remaining text should be pasted into a completely empty script window, or saved to a text file with the indicated name. 'save as CloseAllSyntaxDocs.sbs Sub Main Dim objDocuments As ISpssDocuments Dim i As Integer Set objDocuments = objSpssApp.Documents With objDocuments For i = .SyntaxDocCount - 1 To 0 Step -1 .GetSyntaxDoc(i).Close Next End With End Sub Created on: 05/27/1999