Question

Locked

Gather current time via Script

By jonathon.johnson ·
Is it possible to get the current time from a list of computers previously gathered from another script? We're having an issue with computers not syncing time with the DC for some reason and one of the programs I created for use here uses the local time of the computer for record keeping, and it breaks a couple database reports when the time written to the database is wrong.

I'm trying to track the issue and depending on which computers are regularly off, I'll know better about where/how to start troubleshooting the issue.

This conversation is currently closed to new comments.

13 total posts (Page 1 of 2)   01 | 02   Next
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Are the computers in question keeping time in the BIOS?.

If not then you might need to change the battery(s)on the motherboard(s).

You could try another time clock:

http://tinyurl.com/8zdt

http://tinyurl.com/bdanay

Collapse -

I would hope so

by jonathon.johnson In reply to Are the computers in ques ...

These are all brand new computers. And they are on an intranet. Forgot to add that.

Collapse -

To rule out the possibility, it would be best to change the batts..

by Peconet Tietokoneet In reply to I would hope so

Then set the time correctly in the BIOS, then do the time update on-line, or use the little program that i have put a link to, it is called "atomic clock", it is a very good program if you are having trouble with the NORMAL time clock.

Collapse -

I would hope

by jonathon.johnson In reply to To rule out the possibili ...

Well, I created a batch, albeit a very long batch, to get all the times via "net time", most all the computers are within about 15 minutes of my DC's time. With the exception of a few I found out in another report were actually in the wrong time zone all together.

And changing the batteries on 300+ computers isn't possible. One, they're all under warranty, therefore I cannot open them; and two, I'm the only IT person in my department.

And as I mentioned earlier, it's a intrAnet, so after a quick look at that program, it wouldn't be able to get to the internet to sync with anything. And the second link I'll have to look at later. The firewall here at work blocks it.

I created a batch and copied it to the All Users startup folder on all the computers:

net time \\<DC servername> /set /y

...but from what I've read, that no longer works after Win95. And besides, for it to work, all the users would have to be in the admin group to execute the command I later noticed.

Collapse -

What a bummer....

by Peconet Tietokoneet In reply to I would hope

All of them under Warranty?
Could you not phone up the company and ask them to come out to change the batts?. That way you keep the Warranty. You have a lot of computers at hand. :)

Collapse -

Not possible

by jonathon.johnson In reply to What a bummer....

At any given time we can only have about 5-10% of the network down at any time. Less is better of course. Bringing in that sort of ordeal would bring down 20-30% of the network if it were spaced out over a few days, and right now 86% of the network is being utilized at any given time during regular hours. Off peak hours would be possible, but I'm trying to persue a software fix if at all possible.

I would think there would be some scripted way to do this, but it's just escaping me at the moment.

Collapse -

Yes

by neilb@uk In reply to Gather current time via S ...

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * From Win32_LocalTime")

For Each objItem in colItems
strTime = objItem.Hour & ":" & objItem.Minute & ":" & objItem.Second
dtmTime = CDate(strTime)
Wscript.Echo FormatDateTime(dtmTime, vbFormatLongTime)
Next

Just read your first script's output into the strComputer variable and away you go...

:)

Collapse -

Ahhh

by jonathon.johnson In reply to Yes

Well, I will test this out tomarrow. I got another script running that uses the strComputer varible, and I'm not sure if running this right now will eat the other scripts variable. And since it's been running since lunch (about 3 hours ago), I don't wanna screw it up lol.

How will this spit out the data? The script I was talking of earlier just goes through AD, attempts to ping everything in AD, then I take that list, filter all the fails, take all the successes, put them in a computers.txt file, then run the copyini.vbs script (which loops through the computers.txt file until the end) to copy a new INI to all computers that were "alive".

While I'm quite sure that's all rather tedious and the whole task could probably be scripted, that's my method thusfar.

So back to this topic. Can I just insert this code between the

Do until objFile.AtEndOfStream
strComputer = objFile.Readline
<insert code here>
Loop

????????

If this is of no help, I can post what I use now....sorry, might be going way off on a limb here.

Collapse -

That's exactly what you do

by neilb@uk In reply to Ahhh

Save it as a vbs and run in a CMD window as it will print out the time.

cscript myscripts.vbs

The output will be in the format 12:04:30

The snippet I posted is for a single computer so change

Wscript.Echo FormatDateTime(dtmTime, vbFormatLongTime)
to
Wscript.Echo strComputer & vbtab & FormatDateTime(dtmTime, vbFormatLongTime)

if you're going to put it inside your loop.

Neil :)

p.s. Don't worry about different scripts with the same variable name(s) running at the same time. They don't share memory space or, for that matter, anything else.

Collapse -

Thinking about it a little more

by neilb@uk In reply to Ahhh

You put the systime-extraction routine within the loop that generates your list of "up" computers. No point in dumping out a list only to read it in again.

:)

Back to Software Forum
13 total posts (Page 1 of 2)   01 | 02   Next

Related Discussions

Related Forums