1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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