You can use the following Jam STAPL file to issue the FACTORY instruction in Cyclone® III LS devices.
You can execute the file using quartus_jli with the following command :
quartus_jli -c<cable> -aISSUE_FACTORY factory.jam
If you have other devices in the JTAG chain, you can modify the JAM file by changing the IRSCAN instruction to bypass the other devices. For example, if you have a three-device JTAG chain where the Cyclone III LS device is the second device in the chain, and these other devices each have an IR length of 8, change the line from
IRSCAN 10, 81;
to
IRSCAN 26, FE81FF;