OK the actual code:
‘STEP 1 WMI Call
‘*************************************************
strComputer = “.”
Set objWMIService = GetObject(”winmgmts:” & strComputer & “rootCIMV2″)
Set colItems = objWMIService.ExecQuery( _
“SELECT * FROM Win32_OperatingSystem”,,48)
For Each objItem in colItems
OS = objItem.Version
Next
OS_Installed = Left(CStr(OS),3)…………….’THIS LINE IS THE ONE THAT SOLVED MY ISSUE, i HAD TO CONVERT “OS” TO A STRING IN ORDER TO USE THE LEFT FUNCTION
‘STEP 2 OS found is XP
‘***************************************************
If OS_Installed = “6.1″ Then
WritetoLog “OS is Windows 7 Version Number ” & OS_Installed
‘CONTINUE HERE WITH YOUR OWN LOGIC
End If
‘STEP 3 OS found is WINDOWS 7
‘***************************************************
If OS_Installed = “5.1″ Then
WritetoLog “OS is Windows XP Version Number ” & OS_Installed
‘CONTINUE HERE WITH YOUR OWN LOGIC
End If
Last Wiki Answer Submitted: July 8, 2011 5:57 pm by Ssergio2545 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
‘STEP 1 WMI Call
‘*************************************************
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:\” & strComputer & “rootCIMV2″)
Set colItems = objWMIService.ExecQuery( _
“SELECT * FROM Win32_OperatingSystem”,,48)
For Each objItem in colItems
OS = objItem.Version
Next
OS_Installed = Left(CStr(OS),3)…………….’THIS LINE IS THE ONE THAT SOLVED MY ISSUE, i HAD TO CONVERT “OS” TO A STRING IN ORDER TO USE THE LEFT FUNCTION
‘STEP 2 OS found is XP
‘***************************************************
If OS_Installed = “6.1″ Then
WritetoLog “OS is Windows 7 Version Number ” & OS_Installed
‘CONTINUE HERE WITH YOUR OWN LOGIC
End If
‘STEP 3 OS found is WINDOWS 7
‘***************************************************
If OS_Installed = “5.1″ Then
WritetoLog “OS is Windows XP Version Number ” & OS_Installed
‘CONTINUE HERE WITH YOUR OWN LOGIC
End If
1.5.600 is a string.
Can you post your code ? Are you getting errors ?
Also, are you going to do this to other values ? if so, are the dots in fixed positions ?
Please provide more details.
I too would like to see some of your code thus far, I think I know how to help you but would like to see what you’re doing so far.
Sergio, pseudocode will not help trying to find the error. Why don’t you post your actual code ?
If your code is giving errors, in order to help you we need to know:
-Your code
-The exact error messages your are getting.
Since we don’t have enough information, this is only a guess:
The value coming from the WMI call is probably not a string, but some type of object.
OK the actual code:
‘STEP 1 WMI Call
‘*************************************************
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:\” & strComputer & “rootCIMV2″)
Set colItems = objWMIService.ExecQuery( _
“SELECT * FROM Win32_OperatingSystem”,,48)
For Each objItem in colItems
OS = objItem.Version
Next
OS_Installed = Left(CStr(OS),3)…………….’THIS LINE IS THE ONE THAT SOLVED MY ISSUE, i HAD TO CONVERT “OS” TO A STRING IN ORDER TO USE THE LEFT FUNCTION
‘STEP 2 OS found is XP
‘***************************************************
If OS_Installed = “6.1″ Then
WritetoLog “OS is Windows 7 Version Number ” & OS_Installed
‘CONTINUE HERE WITH YOUR OWN LOGIC
End If
‘STEP 3 OS found is WINDOWS 7
‘***************************************************
If OS_Installed = “5.1″ Then
WritetoLog “OS is Windows XP Version Number ” & OS_Installed
‘CONTINUE HERE WITH YOUR OWN LOGIC
End If
It seems that you have solved the issue.
Thanks for sharing your solution.