there's no need for creating gui apps or scripts, here's a workaround:
connect to remote host via ssh, then type:
ps ax | grep [l]oginwindow
output will look something like
1381 ?? Ss 0:01.36 /System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow console
The PID...