home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 November / PCWorld_2005-11_cd.bin / software / topware / samurize / samurize_1.63.exe / Scripts / ExtendedProps.vbs < prev    next >
Text File  |  2003-03-21  |  10KB  |  348 lines

  1. 'Extended Properties Information VBScript
  2. 'Version 1.5
  3. 'Created 4th June 2002
  4. 'Last Modified 19th March 2003
  5. 'Copyright 2003, Rowan Gillson
  6. 'Not redistributable without express permission from author.
  7. 'Suitable for Windows 2000/Windows XP only.
  8. '
  9. '
  10. 'comments to r_gillson@hotmail.com or ICQ # 14894674
  11.  
  12. on error resume Next
  13.  
  14. Set NetworkInfoSet = CreateObject("Wscript.Network")
  15.  
  16. '-----------------------------------------------------
  17. 'WMI Class Enumerator
  18. '-----------------------------------------------------
  19. Private Sub GetWMI(ComputerName, WMIArray, WMIQuery)
  20.  
  21. Set WMIClass = GetObject("winmgmts:" _
  22.     & "{impersonationLevel=impersonate}!\\" & ComputerName & "\root\cimv2")
  23. Set WMIArray = WMIClass.ExecQuery(WMIQuery)
  24.  
  25. End Sub
  26.  
  27. '-----------------------------------------------------
  28.  
  29.  
  30.  
  31. '-----------------------------------------------------
  32. 'Network information functions
  33. '-----------------------------------------------------
  34. 'Displays external IP address
  35. Function IPAddress(ComputerName, NICIndex)
  36.  
  37. Call GetWMI(ComputerName, IPConfigSet, "Select * from Win32_NetworkAdapterConfiguration where Index=" & NICIndex)
  38.  
  39. For Each objIPInfo in IPConfigSet
  40.     IPAddress = objIPInfo.IPAddress(0)
  41. Next
  42.  
  43. End Function
  44.  
  45. '-----------------------------------------------------
  46. 'Displays logged on username
  47. Function UserName()
  48.     UserName = NetworkInfoSet.UserName
  49. End Function
  50.  
  51. '-----------------------------------------------------
  52. 'Displays computers network name
  53. Function ComputerName()
  54.     ComputerName = NetworkInfoSet.ComputerName
  55. End Function
  56.  
  57. '-----------------------------------------------------
  58. 'Displays domain name for network users, if no domain, displays machine name
  59. Function DomainName()
  60.     DomainName = NetworkInfoSet.UserDomain
  61. End Function
  62.  
  63. '-----------------------------------------------------
  64. 'Displays current Primary Group for domain users only, will not work for non-domain computers
  65. Function PrimaryGroup()
  66.  
  67.     Dim objUser 
  68.     Dim Group, aGroup, PrimaryGroupRID
  69.    
  70.     Set objUser = GetObject("WinNT://" & NTDomain & "/" & NTUser & ",user")
  71.     PrimaryGroupRID = objUser.Get("PrimaryGroupID")
  72.     For Each Group in objUser.Groups
  73.     aGroup = Group.Name
  74.     If Rid(aGroup) = PrimaryGroupRID then
  75.          PrimaryGroup = aGroup
  76.          Exit Function
  77.     End If
  78.     Next
  79.  
  80. End Function
  81.  
  82. Private Function Rid(aGroup)
  83.    
  84.     Dim objGroup, Sid, sTmp, x, b
  85.    
  86.     Set objGroup = GetObject("WinNT://" & NTDomain & "/" & aGroup & ",group")
  87.     Sid = objGroup.Get("objectSID")
  88.     sTmp = ""
  89.     For x = UBound(Sid) to UBound(Sid)-3 Step -1  
  90.         b = AscB(MidB(SID, x + 1))                 
  91.         sTmp = sTmp & Hex(b \ 16) & Hex(b And 15)  
  92.     Next
  93.     Rid = Clng("&H" & sTmp)                       
  94.     Set objGroup = Nothing
  95.  
  96. End Function
  97.  
  98. Private Function NTDomain
  99.  
  100.     Dim varDomain
  101.     Set varDomain = CreateObject("Wscript.Network")
  102.     NTDomain = varDomain.UserDomain
  103.  
  104. End Function
  105.  
  106. Private Function NTUser
  107.  
  108.     Dim varUser
  109.     Set varUser = CreateObject("Wscript.Network")
  110.     NTUser = varUser.UserName
  111.     
  112. End Function
  113.  
  114. '-----------------------------------------------------
  115. 'Displays workgroup or domain depending on membership to either.
  116. Function WorkgroupName(ComputerName)
  117.  
  118. Call GetWMI(ComputerName, SystemInfoSet, "Select * from Win32_ComputerSystem")
  119.  
  120. For Each sWGVar in SystemInfoSet
  121.     sWG = sWGVar.Domain(0)
  122.     If IsNull(sWG) Then
  123.     Else
  124.         WorkgroupName = sWG
  125.     End If
  126. Next
  127.  
  128. End Function
  129.  
  130. '-----------------------------------------------------
  131. 'Displays external IP address
  132. Function DomainRole(ComputerName)
  133.  
  134. Call GetWMI(ComputerName, SystemInfoSet, "Select * from Win32_ComputerSystem")
  135.  
  136. For Each objDomainInfo in SystemInfoSet
  137.     sDomainRoleVar = objDomainInfo.DomainRole
  138. Next
  139.  
  140. Select Case sDomainRoleVar
  141.         Case 0: DomainRole = "Standalone Workstation"        
  142.         Case 1: DomainRole = "Member Workstation"
  143.         Case 2: DomainRole = "Standalone Server"        
  144.         Case 3: DomainRole = "Member Server"
  145.         Case 4: DomainRole = "Backup Domain Controller"            
  146.         Case 5: DomainRole = "Primary Domain Controller"    
  147.     End Select
  148.  
  149. End Function
  150.  
  151. '-----------------------------------------------------
  152.  
  153.  
  154. '-----------------------------------------------------
  155. 'Video display information functions
  156. '-----------------------------------------------------
  157. 'Displays description of video card
  158. Function VideoCardDescription(ComputerName)
  159.  
  160. Call GetWMI(ComputerName, VideoDeviceSet, "Select * from Win32_VideoController where DeviceID='VideoController1'")
  161.  
  162. For Each objVideoInfo in VideoDeviceSet
  163.     VideoCardDescription = objVideoInfo.Description
  164. Next
  165.  
  166. End Function
  167.  
  168. '-----------------------------------------------------
  169. 'Displays video card RAM amount
  170. Function VideoRAM(ComputerName)
  171.  
  172. Call GetWMI(ComputerName, VideoDeviceSet, "Select * from Win32_VideoController where DeviceID='VideoController1'")
  173.  
  174. For Each objVideoInfo in VideoDeviceSet
  175.     VideoRAM = objVideoInfo.AdapterRAM/1048576
  176. Next
  177.  
  178. End Function
  179.  
  180. '-------------------------------------------------------
  181. 'Displays current screen resolution
  182. Function VideoResolution(ComputerName)
  183.  
  184. Call GetWMI(ComputerName, VideoDeviceSet, "Select * from Win32_VideoController where DeviceID='VideoController1'")
  185.  
  186. For Each objVideoInfo in VideoDeviceSet
  187.     VideoResolution = objVideoInfo.CurrentHorizontalResolution & _
  188.     " x " & objVideoInfo.CurrentVerticalResolution
  189. Next
  190.  
  191. End Function
  192.  
  193. '-----------------------------------------------------
  194. 'Displays current refresh rate of video card in MHZ
  195. Function VideoRefreshRateMHz(ComputerName)
  196.  
  197. Call GetWMI(ComputerName, VideoDeviceSet, "Select * from Win32_VideoController where DeviceID='VideoController1'")
  198.  
  199. For Each objVideoInfo in VideoDeviceSet
  200.     VideoRefreshRateMHz = objVideoInfo.CurrentRefreshRate
  201. Next
  202.  
  203. End Function
  204.  
  205. '-----------------------------------------------------
  206. 'Displays current video driver version
  207. Function VideoDriverVersion(ComputerName)
  208.  
  209. Call GetWMI(ComputerName, VideoDeviceSet, "Select * from Win32_VideoController where DeviceID='VideoController1'")
  210.  
  211. For Each objVideoInfo in VideoDeviceSet
  212.     VideoDriverVersion = objVideoInfo.DriverVersion
  213. Next
  214.  
  215. End Function
  216.  
  217. '-----------------------------------------------------
  218.  
  219.  
  220. '-----------------------------------------------------
  221. 'CPU Information Functions
  222. '-----------------------------------------------------
  223. 'Displays CPU Description
  224. Function CPUDescription(ComputerName)
  225.  
  226. Call GetWMI(ComputerName, CPUInfoSet, "Select * from Win32_Processor")
  227.  
  228. For Each objProcessors in CPUInfoSet
  229.     CPUDescription = objProcessors.Name
  230. Next
  231.  
  232. End Function
  233.  
  234. '-----------------------------------------------------
  235. 'Displays CPU Clock speed
  236. Function CPUSpeed(ComputerName)
  237.  
  238. Call GetWMI(ComputerName, CPUInfoSet, "Select * from Win32_Processor")
  239.  
  240. For Each objProcessors in CPUInfoSet
  241.     CPUSpeed = objProcessors.MaxClockSpeed & " MHz"
  242. Next
  243.  
  244. End Function
  245.  
  246. '-----------------------------------------------------
  247. 'Displays CPU FSB speed
  248. Function CPUFSB(ComputerName)
  249.  
  250. Call GetWMI(ComputerName, CPUInfoSet, "Select * from Win32_Processor")
  251.  
  252. For Each objProcessors in CPUInfoSet
  253.     CPUFSB = objProcessors.ExtClock & " MHz"
  254. Next
  255.  
  256. End Function
  257.  
  258. '-----------------------------------------------------
  259. 'Displays CPU Multiplier speed
  260. Function CPUMultiplier(ComputerName)
  261.  
  262. Call GetWMI(ComputerName, CPUInfoSet, "Select * from Win32_Processor")
  263.  
  264. For Each objProcessors in CPUInfoSet
  265.     CPUMultiplier = Round(objProcessors.MaxClockSpeed / objProcessors.ExtClock,1)
  266. Next
  267.  
  268. End Function
  269.  
  270.  
  271. '-----------------------------------------------------
  272. 'Displays CPU Model
  273. Function CPUModel(ComputerName)
  274.  
  275. Call GetWMI(ComputerName, CPUInfoSet, "Select * from Win32_Processor")
  276.  
  277. For Each objProcessors in CPUInfoSet
  278.     CPUModel = objProcessors.Caption
  279. Next
  280.  
  281. End Function
  282.  
  283. '-----------------------------------------------------
  284. 'Displays number of CPU's in system
  285. Function CPUProcessors(ComputerName)
  286.  
  287. Call GetWMI(ComputerName, SystemInfoSet, "Select * from Win32_ComputerSystem")
  288.  
  289. For Each objProcessors in SystemInfoSet
  290.     CPUProcessors = objProcessors.NumberOfProcessors
  291. Next
  292.  
  293. End Function
  294.  
  295. '-----------------------------------------------------
  296.  
  297.  
  298. '-----------------------------------------------------
  299. 'Environment Information Functions
  300. '-----------------------------------------------------
  301. 'Displays OS build number
  302. Function OSBuildNumber(ComputerName)
  303.  
  304. Call GetWMI(ComputerName, OSInfoSet, "Select * from Win32_OperatingSystem")
  305.  
  306. For Each objOperatingSystem in OSInfoSet
  307.     OSBuildNumber = objOperatingSystem.BuildNumber
  308. Next
  309.  
  310. End Function
  311.  
  312. '-----------------------------------------------------
  313. 'Displays OS build type
  314. Function OSBuildType(ComputerName)
  315.  
  316. Call GetWMI(ComputerName, OSInfoSet, "Select * from Win32_OperatingSystem")
  317.  
  318. For Each objOperatingSystem in OSInfoSet
  319.     OSBuildType = objOperatingSystem.BuildType
  320. Next
  321.  
  322. End Function
  323.  
  324. '-----------------------------------------------------
  325. 'Displays Service Pack version info
  326. Function OSSrvPack(ComputerName)
  327.  
  328. Call GetWMI(ComputerName, OSInfoSet, "Select * from Win32_OperatingSystem")
  329.  
  330. For Each objOperatingSystem in OSInfoSet
  331.     OSSrvPack = objOperatingSystem.CSDVersion
  332. Next
  333.  
  334. End Function
  335.  
  336. '-----------------------------------------------------
  337. 'Displays OS Name
  338. Function OSName(ComputerName)
  339.  
  340. Call GetWMI(ComputerName, OSInfoSet, "Select * from Win32_OperatingSystem")
  341.  
  342. For Each objOperatingSystem in OSInfoSet
  343.     OSName = objOperatingSystem.Caption
  344. Next
  345.  
  346. End Function
  347.  
  348. '-----------------------------------------------------