I'm writing a program that gathers computer information using WMI
I have a function that returns the installed OS
Public Function GetOS() As String
On Error Resume Next
Dim strComputer As String
Dim objWMIService As Object
Dim objOperatingSystem As Object
Dim colOperatingSystems
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem In colOperatingSystems
GetOS = GetOS & "001" & objOperatingSystem.Caption & objOperatingSystem.Version & vbCrLf
Next
End Function
And Code to write this to a text file
Dim strFilePath As String
strFilePath = GetDBPath
Open strFilePath & "OutputFile.txt" For Output As #1
Write #1, GetOS
Close #1
the generated text file contains quotation marks that I don't want like this
"001Microsoft Windows 7 Home Premium 6.1.7601
"
instead of what I would like
001Microsoft Windows 7 Home Premium 6.1.7601
does anyone know where the unwanted quotation marks come from and how to get rid of them?
"There is no pleasure in having nothing to do; the fun is having lots to do and not doing it.
." - Andrew Jackson
I have a function that returns the installed OS
Public Function GetOS() As String
On Error Resume Next
Dim strComputer As String
Dim objWMIService As Object
Dim objOperatingSystem As Object
Dim colOperatingSystems
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem In colOperatingSystems
GetOS = GetOS & "001" & objOperatingSystem.Caption & objOperatingSystem.Version & vbCrLf
Next
End Function
And Code to write this to a text file
Dim strFilePath As String
strFilePath = GetDBPath
Open strFilePath & "OutputFile.txt" For Output As #1
Write #1, GetOS
Close #1
the generated text file contains quotation marks that I don't want like this
"001Microsoft Windows 7 Home Premium 6.1.7601
"
instead of what I would like
001Microsoft Windows 7 Home Premium 6.1.7601
does anyone know where the unwanted quotation marks come from and how to get rid of them?
"There is no pleasure in having nothing to do; the fun is having lots to do and not doing it.
." - Andrew Jackson