Thanks for you help.
The problem can be solved by using the "timeout" function but I want to know how to check the logon status then the script can bypass the messagebox rather than use the "timeout" function.

Any idea how to do it? Thanks.