You can save the script right with the generation of the Control Chart. Here is the example from the Scripting Index that shows you how you can do it. You can do the same with the code you displayed, without having to do a separate step.
Names Default To Here( 1 );
dt = Open(
"$SAMPLE_DATA/Quality Control/Coating.jmp"
);
obj = Control Chart(
Sample Size( 1 ),
Chart Col( :Weight ),
Chart Type( Run Chart )
);
obj <<
Save Script to Data Table(
"My Analysis",
<<Prompt( 0 ),
<<Replace( 0 )
);
Jim