How to convert Local time on a computer, into a record in a Access

G

Guest

Part 1
This is what I have, however I need to setup a function that gives me this
info
(10/29/2006 11:30:47 AM), Thank You for your help ROSA

'***List the Local Time on a Computer



'***Description
'***Returns information about the local time configured on a computer.

Set objConn = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")

objConn.Open "DSN=Test;"
objRS.CursorLocation = 3
objRS.Open "SELECT * FROM CDateTable" , objConn, 3, 3
strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colRetrievedItem = objWMIService.ExecQuery _
("Select * from Win32_LocalTime")

For Each objItem in colRetrievedItem
objRS.AddNew
objRS("Day") = objItem.Day
objRS("Day Of Week") = objItem.DayOfWeek
objRS("Hour") = objItem.Hour
objRS("Minute") = objItem.Minute
objRS("Month") = objItem.Month
objRS("Quarter") = objItem.Quarter
objRS("Second") = objItem.Second
objRS("Week In Month") = objItem.WeekInMonth
objRS("Year") = objItem.Year
objRS.Update

Next
 
D

Dave Patrick

Why not grab system 'date' and use a query for the other elements? Something
like;

SELECT field4, DatePart('d',[field4]) AS MyDay, DatePart('w',[field4]) AS
MyDayofWeek, DatePart('h',[field4]) AS MyHour, DatePart('n',[field4]) AS
MyMinute, DatePart('m',[field4]) AS MyMonth, DatePart('q',[field4]) AS MyQ,
DatePart('s',[field4]) AS MySec, DatePart('ww',[field4]) AS MyWeek,
DatePart('yyyy',[field4]) AS MyYear
FROM Table1;


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
| Part 1
| This is what I have, however I need to setup a function that gives me this
| info
| (10/29/2006 11:30:47 AM), Thank You for your help ROSA
|
| '***List the Local Time on a Computer
|
|
|
| '***Description
| '***Returns information about the local time configured on a computer.
|
| Set objConn = CreateObject("ADODB.Connection")
| Set objRS = CreateObject("ADODB.Recordset")
|
| objConn.Open "DSN=Test;"
| objRS.CursorLocation = 3
| objRS.Open "SELECT * FROM CDateTable" , objConn, 3, 3
| strComputer = "."
|
| Set objWMIService = GetObject("winmgmts:" _
| & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
|
| Set colRetrievedItem = objWMIService.ExecQuery _
| ("Select * from Win32_LocalTime")
|
| For Each objItem in colRetrievedItem
| objRS.AddNew
| objRS("Day") = objItem.Day
| objRS("Day Of Week") = objItem.DayOfWeek
| objRS("Hour") = objItem.Hour
| objRS("Minute") = objItem.Minute
| objRS("Month") = objItem.Month
| objRS("Quarter") = objItem.Quarter
| objRS("Second") = objItem.Second
| objRS("Week In Month") = objItem.WeekInMonth
| objRS("Year") = objItem.Year
| objRS.Update
|
| Next
|
 
J

Jim

Dave Patrick said:
Why not grab system 'date' and use a query for the other elements?
Something
like;

SELECT field4, DatePart('d',[field4]) AS MyDay, DatePart('w',[field4]) AS
MyDayofWeek, DatePart('h',[field4]) AS MyHour, DatePart('n',[field4]) AS
MyMinute, DatePart('m',[field4]) AS MyMonth, DatePart('q',[field4]) AS
MyQ,
DatePart('s',[field4]) AS MySec, DatePart('ww',[field4]) AS MyWeek,
DatePart('yyyy',[field4]) AS MyYear
FROM Table1;


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
| Part 1
| This is what I have, however I need to setup a function that gives me
this
| info
| (10/29/2006 11:30:47 AM), Thank You for your help ROSA
|
| '***List the Local Time on a Computer
|
|
|
| '***Description
| '***Returns information about the local time configured on a computer.
|
| Set objConn = CreateObject("ADODB.Connection")
| Set objRS = CreateObject("ADODB.Recordset")
|
| objConn.Open "DSN=Test;"
| objRS.CursorLocation = 3
| objRS.Open "SELECT * FROM CDateTable" , objConn, 3, 3
| strComputer = "."
|
| Set objWMIService = GetObject("winmgmts:" _
| & "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
|
| Set colRetrievedItem = objWMIService.ExecQuery _
| ("Select * from Win32_LocalTime")
|
| For Each objItem in colRetrievedItem
| objRS.AddNew
| objRS("Day") = objItem.Day
| objRS("Day Of Week") = objItem.DayOfWeek
| objRS("Hour") = objItem.Hour
| objRS("Minute") = objItem.Minute
| objRS("Month") = objItem.Month
| objRS("Quarter") = objItem.Quarter
| objRS("Second") = objItem.Second
| objRS("Week In Month") = objItem.WeekInMonth
| objRS("Year") = objItem.Year
| objRS.Update
|
| Next
|
An even better idea is to ask the question in a newsgroup for Access.
Jim
 
G

Guest

This is the complete vbscript, it collects the Data and put it in an Access
DB, I am using it for inventory control.
My Question is. What it the best possible way to collect and convert the
local computer time into a DateTable?

Thank You in Advance for your Help
Rosa

'*** This Audit script that collects the Data and puts it a Access DB ****
'*** inventory control ***




'********* Connect Network Drive ********


Dim WSHNetwork
Set WSHNetwork = WScript.CreateObject("WScript.Network")

WSHNetwork.MapNetworkDrive "Y:", "\\20.2.4.229\Public"


'********* End Of Code *******************

'***List the Local Time on a Computer ****



'***Description
'***Returns information about the local time configured on a computer.

Set objConn = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")

objConn.Open "DSN=Test;"
objRS.CursorLocation = 3
objRS.Open "SELECT * FROM CDateTable" , objConn, 3, 3
strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colRetrievedItem = objWMIService.ExecQuery _
("Select * from Win32_LocalTime")

For Each objItem in colRetrievedItem
objRS.AddNew
objRS("Day") = objItem.Day
objRS("Day Of Week") = objItem.DayOfWeek
objRS("Hour") = objItem.Hour
objRS("Minute") = objItem.Minute
objRS("Month") = objItem.Month
objRS("Quarter") = objItem.Quarter
objRS("Second") = objItem.Second
objRS("Week In Month") = objItem.WeekInMonth
objRS("Year") = objItem.Year
objRS.Update

Next


'************ CDateTable ID ******************

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")

objConnection.Open "DSN=Test;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM CDateTable" , objConnection, _
adOpenStatic, adLockOptimistic
strSearchCriteria = "ID = '0'"
objRecordSet.Find strSearchCriteria


objRecordSet("ID") = "2"
objRecordset.Update


objRecordset.Close

objConnection.Close


'********* End Of Code *******************

'*** List IdTable ************************


Set objConn = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")

objConn.Open "DSN=Test;"
objRS.CursorLocation = 3
objRS.Open "SELECT * FROM IdTable" , objConn, 3, 3
strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colRetrievedItem = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")

For Each objItem in colRetrievedItem
objRS.AddNew
objRS("ComputerName") = objItem.Name
objRS("Manufacturer") = objItem.Manufacturer
objRS("Model") = objItem.Model
objRS.Update

Next

'********* End Of Code *******************

'************ List InfoTable *************

Set objConn = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")

objConn.Open "DSN=Test;"
objRS.CursorLocation = 3
objRS.Open "SELECT * FROM InfoTable" , objConn, 3, 3
strComputer = "."

Set colRetrievedSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product")

For Each objSoftware in colRetrievedSoftware
objRS.AddNew
objRS("NameofSoftware") = objSoftware.Name
objRS("InstallDate") = objSoftware.InstallDate2
objRS("Vendor") = objSoftware.Vendor
objRS("Version") = objSoftware.Version
objRS.Update

Next

'********* End Of Code *******************

'*** List OsTable ************************

Set objConn = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")

objConn.Open "DSN=Test;"
objRS.CursorLocation = 3
objRS.Open "SELECT * FROM OsTable" , objConn, 3, 3
strComputer = "."

Set colRetrievedOSes = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")

For Each objOSes in colRetrievedOSes
objRS.AddNew
objRS("OSTYPE") = objOSes.Caption
objRS("OSVERSION") = objOSes.Version
objRS("ServicePack") = objOSes.ServicePackMajorVersion
objRS.Update

Next

'********* End Of Code *******************

'********** List PTable ******************

Set objConn = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")

objConn.Open "DSN=test;"
objRS.CursorLocation = 3
objRS.Open "SELECT * FROM PTable" , objConn, 3, 3
strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")

For Each objItem in colItems
objRS.AddNew
objRS("Name") = objItem.Name
objRS("Manufacturer") = objItem.Manufacturer
objRS("Maximum Clock Speed") = objItem.MaxClockSpeed
objRS("Processor Type") = objItem.ProcessorType
objRS.Update



Next

'********* End Of Code *******************

'*********** List MTable *****************

Set objConn = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")

objConn.Open "DSN=Test;"
objRS.CursorLocation = 3
objRS.Open "SELECT * FROM MTable" , objConn, 3, 3
strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
("Select * from Win32_PhysicalMemoryArray")

For Each objItem in colItems
objRS.AddNew
objRS("Maximum Capacity") = objItem.MaxCapacity
objRS.Update

Next


objRS.Close
objConn.Close

'********* End Of Code *******************

'**************** IdTable ID *************


Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")

objConnection.Open "DSN=Test;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM IdTable" , objConnection, _
adOpenStatic, adLockOptimistic
strSearchCriteria = "ID = '0'"
objRecordSet.Find strSearchCriteria



objRecordSet("ID") = "2"
objRecordset.Update


'********* End Of Code *******************

'*********** InfoTable ID ****************


Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
"Provider = Microsoft.Jet.OLEDB.4.0; " & _
"Data Source = inventoryTest.mdb"

objRecordSet.Open "UPDATE InfoTable SET " & _
"ID = '2'", _
objConnection, adOpenStatic, adLockOptimistic

objConnection.Close


'********* End Of Code *******************

'********** MTable Id ********************



Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")

objConnection.Open "DSN=Test;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM MTable" , objConnection, _
adOpenStatic, adLockOptimistic
strSearchCriteria = "ID = '0'"
objRecordSet.Find strSearchCriteria



objRecordSet("ID") = "2"
objRecordset.Update

'********* End Of Code *******************

'********** OsTable ID ******************

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")


objConnection.Open "DSN=Test;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM OsTable" , objConnection, _
adOpenStatic, adLockOptimistic
strSearchCriteria = "ID = '0'"
objRecordSet.Find strSearchCriteria



objRecordSet("ID") = "2"
objRecordset.Update

'********* End Of Code *******************

'************ PTable ID ******************

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")

objConnection.Open "DSN=Test;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM PTable" , objConnection, _
adOpenStatic, adLockOptimistic
strSearchCriteria = "ID = '0'"
objRecordSet.Find strSearchCriteria


objRecordSet("ID") = "2"
objRecordset.Update


objRecordset.Close

objConnection.Close


'********* End Of Code *******************


'********* Remove Network Drive **********

'Set WshNetwork = WScript.CreateObject("WScript.Network")

'WshNetwork.RemoveNetworkDrive "Y:", True, True


'********* End Of Code ********************
 
Top