You can check the state of Optional stop in VB
'turn off M01 bnt
if getOEMLED(65)=true Then
'Optional stop is on turn it off
DoOEMButton(177)
End If
'turn on M01 bnt
if getOEMLED(65)=false Then
'Optional stop is off turn it on
DoOEMButton(177)
End If