Operators do not work suddenly

A week ago, I wrote this script, which runs when you log in, and then greets you depending on the time of day. This morning, unexpectedly unexpectedly, he said: "Invalid time" (this would be so if all the other options elseifdid not correspond to the time). This has worked until today.

Here is my code:

Set objShell = CreateObject("WScript.Shell")
ctime = Time()
usr = objShell.ExpandEnvironmentStrings("%username%")
if ctime > "06:00:00" and ctime < "12:00:00" then
    objShell.Popup "Good Morning, " & usr, 5, "", 4096
elseif ctime > "12:00:00" and ctime < "18:00:00" then
    objShell.Popup "Good Afternoon, " & usr, 5, "", 4096
elseif ctime > "18:00:00" and ctime < "23:59:59" then
    objShell.Popup "Good evening, " & usr, 5, "", 4096
elseif ctime > "00:00:00" and ctime < "06:00:00" then
    objShell.Popup "Good night, " & usr, 5, "", 4096
else
    objShell.Popup "Invalid time", 5, "", 4096
end if

EDIT: It seems to be working again, now that it’s 10 hours, but for some reason it didn’t work until 10, I think there is still an error in my code?

+4
source share
1 answer

. (VBScript) ( ); , , #09:10:12# "9:10:12" " 9:10:12". , (#), #06:00:00# "06:00:00".

: , #06:00:00# #12:00:00# #18:00:00# - if elseif .

,

if ctime > "06:00:00" and ctime < "12:00:00" then

if ctime >= #06:00:00# and ctime < #12:00:00# then

if ctime > #06:00:00# and ctime <= #12:00:00# then

elseif.

+6
source

All Articles