Documentation
IsWorkstationLocked [/w:l[ock]] [/w:u[nlock]] [/w:t[oggle]] [/w:99999] [/w:HH:MM]
Reports whether the workstation is locked, or waits for the given status.

/w:lock        Waits until the workstation is locked, then returns.
/w:unlock      Waits until the workstation is unlocked, then returns.
/w:toggle      Waits until the workstation changes state, then returns.
               (i.e. if it's locked, waits until unlock, otherwise until lock).

/w:99999       Times out after the given number of seconds, no matter what.
/w:HH:MM       Times out after the given (date and) time, no matter what.

Batch files can use this command's return value to determine the status of the workstation.
ERRORLEVEL 0 means the workstation is not locked.
ERRORLEVEL 1 means the workstation is locked.
ERRORLEVEL 2 means no attempt was made to check the status of the workstation (e.g. this help was displayed).
ERRORLEVEL 3 or higher means an error has occurred.