archrival Posted May 4, 2005 Share Posted May 4, 2005 (edited) Fairly simple, requires newest beta version. This will ask you to enter a machine name (it defaults to your own) and then it will retrieve the Model Name and serial number of the monitor. Comments welcome. expandcollapse popup$wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 _StrComputer() If Ping($strComputer, 200) = 0 Then MsgBox(0, "Error", $strComputer & " could not be reached, please enter another.") _StrComputer() EndIf _ObjWMI() Func _ObjWMI() Global $objWMIService = ObjGet ("winmgmts:\\" & $strComputer & "\root\CIMV2") _ObjWMICheck() EndFunc Func _ObjWMICheck() If $objWMIService = "" Then MsgBox(0, "WMI Error", "WMI not running on " & $strComputer & ", please enter another computer name.") _StrComputer() _ObjWMI() EndIf EndFunc $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_DesktopMonitor", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) $j = 0 $msg = "" If IsObj ($colItems) Then For $objItem In $colItems $PNPDeviceID = $objItem.PNPDeviceID $screenwidth = $objItem.ScreenWidth If $screenwidth = 0 Then ExitLoop $monedid = RegRead("\\" & $strComputer & "\HKEY_LOCAL_MACHINE\System\CurrentControlSet\Enum\" & $PNPDeviceID & "\Device Parameters", "EDID") Dim $edidarray[StringLen($monedid) ] $edidarray[0]= (StringLen($monedid) / 2) + 1 For $i = 1 To StringLen($monedid) Step 2 $j = $j + 1 $edidarray[$j] = Dec(StringMid($monedid, $i, 2)) Next Next $ser = _FindMonitorSerial() $name = _FindMonitorName() MsgBox(0, "Monitor Information", "Monitor Name: " & $name & @CRLF & "Serial Number: " & $ser) Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_DesktopMonitor") EndIf Func _FindMonitorSerial() $sernumstr = "" $sernum = 0 For $i = 1 To (UBound($edidarray) / 2) - 4 If $edidarray[$i] = "0" And $edidarray[$i + 1] = "0" And $edidarray[$i + 2] = "0" And $edidarray[$i + 3] = "255" And $edidarray[$i + 4] = "0" Then $sernum = $i + 4 EndIf Next If $sernum <> 0 Then $endstr = 0 $sernumstr = "" For $i = 1 To 13 If $edidarray[$sernum + $i] = "10" Then $endstr = 1 Else If $endstr = 0 Then $sernumstr = $sernumstr & Chr($edidarray[$sernum + $i]) EndIf EndIf Next Else $sernumstr = "" EndIf Return $sernumstr EndFunc Func _FindMonitorName() $name = 0 For $i = 1 To (UBound($edidarray) / 2) - 4 If $edidarray[$i] = "0" And $edidarray[$i + 1] = "0" And $edidarray[$i + 2] = "252" And $edidarray[$i + 3] = "0" Then $name = $i + 3 EndIf Next If $name <> 0 Then $endstr = 0 $namestr = "" For $i = 1 To 13 If $edidarray[$name + $i] = "10" Then $endstr = 1 Else If $endstr = 0 Then $namestr = $namestr & Chr($edidarray[$name + $i]) EndIf EndIf Next Else $namestr = "" EndIf Return $namestr EndFunc Func _StrComputer() Global $strComputer = InputBox("Computer Name", "Enter Computer Name:", StringLower(@ComputerName), "", 100, 120) If @error = 1 Then Exit EndFunc Edited May 4, 2005 by archrival Link to comment Share on other sites More sharing options...
iceberg Posted May 5, 2005 Share Posted May 5, 2005 great idea to create this script. but it doesn't work for me though. mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
iceberg Posted May 5, 2005 Share Posted May 5, 2005 the above screenshot was from a Compaq monitor and it didn't work. but i tried on a Phillips 107S5 monitor and it worked fine! gd job! mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
archrival Posted May 5, 2005 Author Share Posted May 5, 2005 the above screenshot was from a Compaq monitor and it didn't work. but i tried on a Phillips 107S5 monitor and it worked fine!gd job!<{POST_SNAPBACK}>Yeah, not every monitor will return the serial number. My monitor at home has the serial number 000001, I imagine all KDS VS-190 monitors return that same serial number. I wrote this script because we have Dell flat panels and I need to make sure they stay with the particular PC. When I rolled out the PCs, I forgot to mark down the monitor serial number. I'm an efficient type of lazy, yes I figured out how to retrieve it from my desk, but I don't feel like going around to all the PCs and writing down the serial numbers. So this works for me, most of the code I post on here is stuff I need for my job and I just like to share. Link to comment Share on other sites More sharing options...
spiderblues Posted November 12, 2005 Share Posted November 12, 2005 Yeah, not every monitor will return the serial number. My monitor at home has the serial number 000001, I imagine all KDS VS-190 monitors return that same serial number. I wrote this script because we have Dell flat panels and I need to make sure they stay with the particular PC. When I rolled out the PCs, I forgot to mark down the monitor serial number. I'm an efficient type of lazy, yes I figured out how to retrieve it from my desk, but I don't feel like going around to all the PCs and writing down the serial numbers. So this works for me, most of the code I post on here is stuff I need for my job and I just like to share.That's exact what I'm looking for, but it doesn't work on my pc!!!No model and serial is shown!It's stored, because Everest and AIDA shows the information...Do you have any idea why?I'm using the latest beta 3.1.1.87thanks Link to comment Share on other sites More sharing options...
archrival Posted November 13, 2005 Author Share Posted November 13, 2005 That's exact what I'm looking for, but it doesn't work on my pc!!!No model and serial is shown!It's stored, because Everest and AIDA shows the information...Do you have any idea why?I'm using the latest beta 3.1.1.87thanksI'm not too sure, this code has to decode what is already stored in Windows. I'm also not sure if those programs use WMI, I doubt it. Just make sure WMI is running and you have read access to "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Enum\DISPLAY". You could check the registry entries under Display for Device Parameters, that is decoded to determine the Serial and Name. If it exists, then I'm not sure, I'm willing to bet it does not. Those programs could possibly read the DDC/EDID information directly, that may be possible now via DLL calls, but that's not something I'd be able to figure out anytime soon.I changed around the code a little, it's basically the same, I just don't ask to enter a new PC name if the entered one fails.expandcollapse popup$strComputer = InputBox("Computer Name", "Enter Computer Name:", StringLower(@ComputerName), "", 100, 120) If @error = 1 Then Exit If Ping($strComputer, 200) = 0 Then MsgBox(0, "Error", $strComputer & " could not be reached.") Exit EndIf $objWMIService = ObjGet ("winmgmts:\\" & $strComputer & "\root\CIMV2") If $objWMIService = "" Then MsgBox(0, "WMI Error", "WMI not running on " & $strComputer & ".") Exit EndIf $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_DesktopMonitor", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) $j = 0 $msg = "" If IsObj ($colItems) Then For $objItem In $colItems $PNPDeviceID = $objItem.PNPDeviceID $screenwidth = $objItem.ScreenWidth If $screenwidth = 0 Then ExitLoop $monedid = RegRead("\\" & $strComputer & "\HKEY_LOCAL_MACHINE\System\CurrentControlSet\Enum\" & $PNPDeviceID & "\Device Parameters", "EDID") Dim $edidarray[StringLen($monedid) ] $edidarray[0]= (StringLen($monedid) / 2) + 1 For $i = 1 To StringLen($monedid) Step 2 $j = $j + 1 $edidarray[$j] = Dec(StringMid($monedid, $i, 2)) Next Next $ser = _FindMonitorSerial() $name = _FindMonitorName() MsgBox(0, "Monitor Information", "Monitor Name: " & $name & @CRLF & "Serial Number: " & $ser) Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_DesktopMonitor") EndIf Func _FindMonitorSerial() $sernumstr = "" $sernum = 0 For $i = 1 To (UBound($edidarray) / 2) - 4 If $edidarray[$i] = "0" And $edidarray[$i + 1] = "0" And $edidarray[$i + 2] = "0" And $edidarray[$i + 3] = "255" And $edidarray[$i + 4] = "0" Then $sernum = $i + 4 EndIf Next If $sernum <> 0 Then $endstr = 0 $sernumstr = "" For $i = 1 To 13 If $edidarray[$sernum + $i] = "10" Then $endstr = 1 Else If $endstr = 0 Then $sernumstr = $sernumstr & Chr($edidarray[$sernum + $i]) EndIf EndIf Next Else $sernumstr = "" EndIf Return $sernumstr EndFunc Func _FindMonitorName() $name = 0 For $i = 1 To (UBound($edidarray) / 2) - 4 If $edidarray[$i] = "0" And $edidarray[$i + 1] = "0" And $edidarray[$i + 2] = "252" And $edidarray[$i + 3] = "0" Then $name = $i + 3 EndIf Next If $name <> 0 Then $endstr = 0 $namestr = "" For $i = 1 To 13 If $edidarray[$name + $i] = "10" Then $endstr = 1 Else If $endstr = 0 Then $namestr = $namestr & Chr($edidarray[$name + $i]) EndIf EndIf Next Else $namestr = "" EndIf Return $namestr EndFunc Link to comment Share on other sites More sharing options...
Rahul Rohela Posted November 14, 2005 Share Posted November 14, 2005 Hi, I am getting following error... Any Idea... Link to comment Share on other sites More sharing options...
spiderblues Posted November 14, 2005 Share Posted November 14, 2005 look at this: http://www.autoitscript.com/forum/index.ph...ndpost&p=124058 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now