How do i disable spell check from command line

I want to be able to switch off (and on obviously) the spell checker from time to time, because when our students are making certain tests they are not allowed to use spell checking. I do not want to do this manually on all the computers, but rather scripting it centralized.
Is it possible?

Which platform and LO version?

I am not sure how effective (or safe) this would be, but if you are looking to script a solution, you could consider taking a copy of the registry file (registrymodifications.cxu) in the User Profile before and after turning on/off the automatic spelling options. Under Tools > Options… > Languages Settings > Writing aids > Options:

  • Check spelling as you type
  • Check grammar as you type

You could then copy over the version you require, before and after a test. An edited diff on before / after copies of this file would seem to indicate these are the entries that matter if you want to use a regular expression to target just these XML elements:

516c516
< <item oor:path="/org.openoffice.Office.Linguistic/General/DictionaryList"><prop oor:name="ActiveDictionaries" oor:op="fuse"><value><it>IgnoreAllList</it></value></prop></item>
---
> <item oor:path="/org.openoffice.Office.Linguistic/General/DictionaryList"><prop oor:name="ActiveDictionaries" oor:op="fuse"><value><it>standard.dic</it><it>IgnoreAllList</it></value></prop></item>
519c519
< <item oor:path="/org.openoffice.Office.Linguistic/GrammarChecking"><prop oor:name="IsAutoCheck" oor:op="fuse"><value>true</value></prop></item>
---
> <item oor:path="/org.openoffice.Office.Linguistic/GrammarChecking"><prop oor:name="IsAutoCheck" oor:op="fuse"><value>false</value></prop></item>
818c818
< <item oor:path="/org.openoffice.Office.Linguistic/SpellChecking"><prop oor:name="IsSpellAuto" oor:op="fuse"><value>true</value></prop></item>
---
> <item oor:path="/org.openoffice.Office.Linguistic/SpellChecking"><prop oor:name="IsSpellAuto" oor:op="fuse"><value>false</value></prop></item>

Thanks for your answer oweng.
Unfortunately this is just a QD solution. As you pointed out it might not be so secure. At first I didn’t understand what you meant, but now I realize that from the sake of the test the students are undertaking it is not secure. The students can easily activate the spellcheck again, the same way I deactivated it. I thought that a write protect on the file should do the trick, but no, “something” enabled the write right on the file again. So… I changed the owner of the file to root, but that didn’t work since LibreOffice (or “something”) changed the owner back to the logged on user.

So… I guess I’m back to square uno

Oh btw, I’m using LO 3.5 on Ubuntu 12.04

Any other ideas?

Yeah, I was just thinking of quick and dirty solutions also. Refer my second answer.

If you wish to lock down the settings you are probably going to need to play with the LibreOffice API to turn off / suppress display of the Tools > Options menu item. This should not actually be too difficult. Refer this thread about disabling, for example, the File > Open… menu item. The very last example under the Office Development section of the Developer’s Guide Examples is what you are after i.e., DisableCommandsTest.

I have not read up on what the exact command/s required are, so will leave this to you.