Jump to content

Recommended Posts

Posted

I have installed Windows XP SP3. I have a logon script that will put a logo in the icon tray and with a balloon greet the user with good morning, good afternoon or good evening depending on the time of day. Since I have install XP SP3 the timing is all wrong. In the evening it displays as good morning in the morning it says nothing at all.

It still works fine with Windows XP SP2.

 

This is the code:

 

if time >"00:00:01" and time<"12:00:00" then timemessage = "Good morning " & objUser.firstname & ", welcome to the network"
if time >"12:00:01" and time<"18:30:00" then timemessage = "Good afternoon " & objUser.firstname & ", welcome to the network"
if time >"18:30:01" and time<"23:59:59" then timemessage = "Good evening " & objUser.firstname & ", welcome to the network"
Message "HCHS", 1, timemessage, 4

 

Any suggestions as to why please?

Posted

Is it a VBS Script?

When i copy the code into notepad and save it as a vbs (time.vbs) i get the following error

 

Script: C:\time.vbs

Line: 4

Char: 2

Error: Type mismatch: 'Message'

Code: 800A000D

Source: Microsoft VBScript runtime error

Dont think it likes "Message"

Posted

Yer is it you need to register a DLL and use this bit of code:

 

Sub Message (strTitle, intIcon, strMessage, intSeconds)

on error resume next

If bTrayIcon = FALSE Then

 

Set objTrayIcon = CreateObject ("SystemTray.Application")

If Err.Number = 0 Then

bTrayIcon = TRUE

objTrayIcon.CreateIcon "\\server\NETLOGON\bin\hchs.ico", "HCHS"

Else

bTrayIcon = FALSE

End If

On Error Goto 0

End If

 

If bTrayIcon = TRUE Then

Call objTrayIcon.ShowBalloon (CStr (strTitle), CInt (intIcon), CStr (strMessage))

WScript.Sleep (intSeconds * 1000)

Else

on error resume next

objShell.LogEvent 5-intIcon, "userstudentcheck.VBS wrote the following to the event log:" & vbCR & vbCR & "''" & strMessage & "''"

End If

 

End Sub

 

If your interested in doing this in a script of your own I can post full details later on today if you like?

Posted

Yes it is. I also managed to get the script to tell the user how many unread e-mails they have.

 

I have got to do something at dinner time today i upload the code when i get back.

  • Thanks 1
Posted

Can I jump in on this thread and ask what I would need to do just to start using VB script for logins etc.

I am now in a CC3 environmet but in my previous life I used kix script for login scripts.

Posted
I don’t work in a CC3 environment, just plain Windows. All you need for the plain Windows one is notepad to write to code then when the script is complete you place it in a group policy.
Posted
OK the bit that tells you how many messages you have needs Outlook to be configured. But the script can also configure outlook for exchange automatically.
Posted (edited)
have you tried CDate("2:07:30 PM") as this will convert it to a date/time value manually rather that haphazardly if the scripting host feels like it. Edited by SYNACK
Posted
Are the Date & Time and Time Zone set to GMT? As of course our American cousins operate MM/DD/YYYY whereas of course we use DD/MM/YYYY like everyone else! :)
Posted
have you tried CDate("2:07:30 PM") as this will convert it to a date/time value manually rather that haphazardly if the scripting host feels like it.

 

How would i got about that please?

 

Are the Date & Time and Time Zone set to GMT? As of course our American cousins operate MM/DD/YYYY whereas of course we use DD/MM/YYYY like everyone else! :)

 

That bit is fine

 

Thanks

Posted

Hmmm, did you install XP SP3 on top of an existing SP2 installation or install from new?

 

If you haven't installed SP3 from new, I would recommend it. If that still doesn't solve the problem I wonder if SP3 has changed some default behaviour the way VBS run?

Posted
It was an install over SP2. What I am going to do is test it on a few other machines and see if it isn't my dodgy laptop.
Posted

This should probably work:

if time > CDate("00:00:01") and time< CDate("12:00:00)" then timemessage = "Good morning " & objUser.firstname & ", welcome to the network"

 

If not I would separate out the variables like this:

if (Hour (Now) >= 0  and Hour (Now) < 12 ) then timemessage = "Good morning " & objUser.firstname & ", welcome to the network"
if (Hour (Now) > 12  and Hour (Now) < 16 ) then 
   if (Hour (Now) = 14 and Minute (Now) < 30 ) then timemessage = "Good afternoon " & objUser.firstname & ", welcome to the network"
end if

 

This will also sort it out to run no matter what the regional settings are set to.

  • Thanks 1
Posted

Try adding the following to the top of your script to force the script to use English UK settings:

 

SetLocale(2057)

 

I think I read somewhere that SP3 messes up the locale when using vbscript or jscript so you get the American time (10:05:24 PM). In any case, it's good practise to add it to any script that uses date or time so that you know what format will be used.

  • Thanks 1
Posted (edited)

I know you already solved the problem, but something I find handy to solve VBS script problems is to use the msgbox function to put a message on screen showing whatever data you're having trouble with.

 

e.g in this case I would have added

msgbox time

to the script to actually display what time the program is seeing in a messagebox, then it might help give you an idea as to what the problem is. I use it all the time to check the correct data is being used by scripts when I'm writing them, very handy.

 

Mike.

Edited by maniac
Posted
Good idea, if i am troubleshooting i used echo's. But that will display the time as well so it would diffidently helped us with that little bug.
Posted

Nice idea this, but I'm having trouble getting it to work.

 

FB-Greatermanchester, you said before that you "need to register a dll" - what dll?

Is it one you wrote?

 

It would be really great if you could post up a quick, simple, complete "how to" for this to work :)

 

Cheers,

 

Pete

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...