R
Rodney
Ok, I have some code that on a Button click will check
the Service Pack Version of the given computer in the
Str=Me.Form.Controls.Item("[Cmp Name]") line, and write
it to a text file called test.txt.
So the file ends up looking like this:
ServicePackVersion
4.0
acct1 (computer name)
Now a few questions:
#1, Am I able to write this to a table instead?
#2, If I can't write directly to a table, then in the
code, can I format it comma delimited so it's easy to
import?
Here's my code below. Thanks
Private Sub Command14_Click()
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile
("c:\scripts\test.txt", True)
strComputer = Me.Form.Controls.Item("[Cmp Name]")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer
& "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem")
objTextFile.WriteLine "ServicePackVersion"
For Each objOperatingSystems In colOperatingSystems
objTextFile.WriteLine
objOperatingSystems.ServicePackMajorVersion _
& "." &
objOperatingSystems.ServicePackMinorVersion
objTextFile.WriteLine Me.Form.Controls.Item("[Cmp Name]")
Next
objTextFile.Close
End Sub
the Service Pack Version of the given computer in the
Str=Me.Form.Controls.Item("[Cmp Name]") line, and write
it to a text file called test.txt.
So the file ends up looking like this:
ServicePackVersion
4.0
acct1 (computer name)
Now a few questions:
#1, Am I able to write this to a table instead?
#2, If I can't write directly to a table, then in the
code, can I format it comma delimited so it's easy to
import?
Here's my code below. Thanks
Private Sub Command14_Click()
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile
("c:\scripts\test.txt", True)
strComputer = Me.Form.Controls.Item("[Cmp Name]")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer
& "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem")
objTextFile.WriteLine "ServicePackVersion"
For Each objOperatingSystems In colOperatingSystems
objTextFile.WriteLine
objOperatingSystems.ServicePackMajorVersion _
& "." &
objOperatingSystems.ServicePackMinorVersion
objTextFile.WriteLine Me.Form.Controls.Item("[Cmp Name]")
Next
objTextFile.Close
End Sub