Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for is6432os.vbs

(view source code of is6432os.vbs as plain text)

  1. Option Explicit
  2.  
  3. Dim intAddressWidth
  4. Dim colItems, objItem, objWMIService
  5. Dim strMsg
  6.  
  7. If WScript.Arguments.Count > 0 Then Syntax
  8.  
  9. On Error Resume Next
  10.  
  11. Set objWMIService = GetObject( "winmgmts://./root/cimv2" )
  12. If Err Then ShowError
  13.  
  14. Set colItems = objWMIService.ExecQuery( "SELECT * FROM Win32_Processor", , 48 )
  15. If Err Then ShowError
  16.  
  17. For Each objItem in colItems
  18. 	intAddressWidth = objItem.AddressWidth
  19. 	strMsg = "Windows  " & vbTab & ": " & intAddressWidth   & "-bit" & vbCrLf _
  20. 	       & "Processor" & vbTab & ": " & objItem.DataWidth & "-bit"
  21. Next
  22.  
  23. On Error Goto 0
  24.  
  25. WScript.Echo strMsg
  26.  
  27. WScript.Quit intAddressWidth
  28.  
  29.  
  30. Sub Syntax
  31. 	strMsg = "is6432os.vbs,  Version 1.00" & vbCrLf _
  32. 	       & "Detect if the OS is 32-bit or 64-bit" & vbCrLf & vbCrLf _
  33. 	       & "Usage:"  & vbTab & "IS6432OS.VBS" & vbCrLf & vbCrLf _
  34. 	       & "Return:" & vbTab & "return code 32 for 32-bit OS, 64 for 64-bit, or 1 for error" & vbCrLf & vbCrLf _
  35. 	       & "Written by Rob van der Woude" & vbCrLf _
  36. 	       & "http://www.robvanderwoude.com"
  37. 	WScript.Echo strMsg
  38. 	WScript.Quit 1
  39. End Sub
  40.  
  41.  
  42. Sub ShowError
  43. 	WScript.Echo "Error #" & err.Number & ": " & Err.Description
  44. 	WScript.Quit 1
  45. End Sub
  46.  

page last modified: 2024-04-16; loaded in 0.0084 seconds