This should do the stuff (you may need to call vl-load-com to initialize ActiveX support):
;
; == Function MePutAllLayers
; Controls Freeze, LayerOn, Lock, Plottable or ViewportDefault for all Layers.
; Arguments [Type]:
; Sym = Symbol [SYM]:
; - 'vla-put-Freeze
; - 'vla-put-LayerOn
; - 'vla-put-Lock
; - 'vla-put-Plottable
; - 'vla-put-ViewportDefault
; Mde = Mode [BOOLEAN]:
; - :vlax-true
; - :vlax-false
; Return [Type]:
; > Null
; Notes:
; - Some symbols require a vla-regen to make the changes visible.
;
(defun MePutAllLayers (Sym Mde / AcaDoc)
(setq AcaDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(vlax-for Obj (vla-get-Layers AcaDoc)
(vl-catch-all-error-p
(vl-catch-all-apply Sym (list Obj Mde))
)
)
(princ)
)
Use:
(MePutAllLayers 'vla-put-Freeze :vlax-true)
Edited: Notes added