Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

517 lines
14 KiB

  1. var remoteServer = "";//local if not set
  2. var wbemCimtypeString = 8
  3. function displayTableSegment(outerDiv, dataArray)
  4. {
  5. var tableElement = document.all[outerDiv];
  6. var repeatItemHTML = tableElement.outerHTML;
  7. var strHTML = "";
  8. var noOfInstances = dataArray[0];
  9. for(var i=0; i < noOfInstances; i++)
  10. {
  11. for(var k=0; k < dataArray[i+1].length; k++)
  12. if (dataArray[i+1][k] != null)
  13. {
  14. tableElement.all(outerDiv + "_" + (k+1)).innerHTML= dataArray[i+1][k];
  15. }
  16. strHTML = strHTML + tableElement.outerHTML;
  17. }
  18. tableElement.outerHTML = strHTML;
  19. }
  20. function DisplayLocStrings() {
  21. WaitMessage.innerHTML = MSG_WAIT;
  22. Refresh.innerHTML = TAG_REFRESH;
  23. SetProgressBarImage();
  24. with(Specifications.all) {
  25. Caption.innerHTML = TAG_SPECIFICATIONS;
  26. label1.innerHTML = TAG_SYSTEMMODEL + ":";
  27. label2.innerHTML = TAG_BIOSVERSION + ":";
  28. }
  29. with(Processor.all) {
  30. Caption.innerHTML = TAG_PROCESSOR;
  31. label1.innerHTML = TAG_VERSION + ":";
  32. label2.innerHTML = TAG_SPEED + ":";
  33. }
  34. with(OS.all) {
  35. Caption.innerHTML = TAG_OS;
  36. label1.innerHTML = TAG_VERSION + ":";
  37. label2.innerHTML = TAG_SP + ":";
  38. label3.innerHTML = TAG_LOCATION + ":";
  39. label4.innerHTML = TAG_PID + ":";
  40. label5.innerHTML = TAG_HOTFIX + ":";
  41. // label6.innerHTML = TAG_LANGUAGE + ":";
  42. }
  43. with(General_Comp_Info.all) {
  44. Caption.innerHTML = TAG_GENCOMPINFOCAPTION;
  45. label1.innerHTML = TAG_SYSTEMNAME + ":";
  46. label2.innerHTML = TAG_DOMAIN + ":";
  47. label3.innerHTML = TAG_TIMEZONE + ":";
  48. //label4.innerHTML = TAG_COUNTRYREGION + ":";
  49. // label5.innerHTML = TAG_CONNECTION + ":";
  50. // label6.innerHTML = TAG_PRXYSVR + ":";
  51. // label7.innerHTML = TAG_IPADDR + ":";
  52. // label8.innerHTML = TAG_IPXADDR + ":";
  53. label4.innerHTML = TAG_CONNECTION + ":";
  54. label5.innerHTML = TAG_PRXYSVR + ":";
  55. label6.innerHTML = TAG_IPADDR + ":";
  56. label7.innerHTML = TAG_IPXADDR + ":";
  57. }
  58. with(Memory.all) {
  59. Caption.innerHTML = TAG_MEMORY;
  60. label1.innerHTML = TAG_CAPACITY + ":";
  61. }
  62. with(Local_Disk.all) {
  63. Caption.innerHTML = TAG_LOCALDISK;
  64. label1.innerHTML = TAG_TOTALCAPACITY + ":";
  65. label2.innerHTML = TAG_SUMHARDDRIVES + ":";
  66. label3.innerHTML = TAG_USED + ":";
  67. label4.innerHTML = TAG_FREE + ":";
  68. }
  69. }
  70. function dispatchFunction() {
  71. document.body.style.cursor= "wait";
  72. document.body.scroll= "no";
  73. DisplayLocStrings();
  74. window.setTimeout("LoadChores(0)", TIMEOUT);
  75. }
  76. var INCR_UNIT = 100/6;//move progress bar in increments of INCR_UNIT
  77. function LoadChores(taskId) {
  78. try {
  79. switch(taskId)
  80. {
  81. case 0:
  82. remoteServer = GetServerName();//set remoteServer
  83. ShowServerName(TAG_PROPERTIES);
  84. break;
  85. case 1:
  86. DrawProgressBar(INCR_UNIT, TAG_SPECIFICATIONS);
  87. break;
  88. case 2:
  89. getComputerInfo();
  90. break;
  91. case 3:
  92. DrawProgressBar(INCR_UNIT * 2, TAG_PROCESSOR);
  93. break;
  94. case 4:
  95. getProcessorInfo();
  96. break;
  97. case 5:
  98. DrawProgressBar(INCR_UNIT * 3, TAG_OS);
  99. break;
  100. case 6:
  101. getOSInfo();
  102. break;
  103. case 7:
  104. DrawProgressBar(INCR_UNIT * 4, TAG_GENCOMPINFO);
  105. break;
  106. case 8:
  107. getGeneralInfo();
  108. break;
  109. case 9:
  110. DrawProgressBar(INCR_UNIT * 5, TAG_MEMORY);
  111. break;
  112. case 10:
  113. getMemoryInfo();
  114. break;
  115. case 11:
  116. DrawProgressBar(INCR_UNIT * 6, TAG_LOCALDISK);
  117. break;
  118. case 12:
  119. displayTotalLogicalDrivesInfo();
  120. break;
  121. default:
  122. taskId = -1;
  123. _headerOnly.style.display = "none";
  124. _wholeBody.style.display = "";
  125. document.body.style.cursor= "default";
  126. document.body.scroll= "auto";
  127. }
  128. if(taskId >= 0)
  129. window.setTimeout("LoadChores(" + ++taskId + ")", TIMEOUT);
  130. }
  131. catch (e) {
  132. HandleErr(e);
  133. }
  134. }
  135. // The array of pointers to the array containing instance information.
  136. // The first member contains the number of instances the structure contains.
  137. //******** Summary page functions goes here ******************************
  138. function getComputerInfo()
  139. {
  140. var locator = wbemlocator;
  141. var service = locator.ConnectServer(remoteServer);
  142. service.Security_.impersonationlevel = 3;
  143. var col1 = new Enumerator(service.ExecQuery("Select * from win32_ComputerSystem"));
  144. var mainArray = new Array();
  145. if(!col1.atEnd())
  146. {
  147. var col2 = new Enumerator(service.ExecQuery("Select * from win32_BIOS"));
  148. if (!col2.atEnd())
  149. {
  150. var strVersion = "", strBIOSVersion = "", strSMBIOSVersion = "", strManufacturer = "";
  151. var q = col2.item();
  152. var collProp = new Enumerator(q.Properties_);
  153. for(; !collProp.atEnd(); collProp.moveNext())
  154. {
  155. var prop = collProp.item();
  156. if(prop.Name == "SMBIOSBIOSVersion")
  157. {
  158. if(prop.CIMType == wbemCimtypeString)
  159. {
  160. strSMBIOSVersion = prop.Value;
  161. }
  162. }
  163. else if(prop.Name == "Manufacturer")
  164. {
  165. if(prop.CIMType == wbemCimtypeString)
  166. {
  167. strManufacturer = prop.Value;
  168. }
  169. }
  170. else if(prop.Name == "BIOSVersion")
  171. {
  172. if(prop.IsArray)
  173. {
  174. if(prop.Value)
  175. {
  176. var safearr = new VBArray(prop.Value);
  177. for(var i=0; i<=safearr.ubound(1); i++)
  178. strBIOSVersion += (i!=0 ? ", " : "") + safearr.getItem(i);
  179. }
  180. }
  181. }
  182. else if(prop.Name == "Version")
  183. {
  184. if(prop.CIMType == wbemCimtypeString)
  185. {
  186. strVersion = prop.Value;
  187. }
  188. }
  189. }
  190. if(strSMBIOSVersion)
  191. {
  192. strBIOSVersion = (strManufacturer ? strManufacturer : " ") + " " + strSMBIOSVersion;
  193. }
  194. if(!strBIOSVersion)
  195. {
  196. if(strVersion)
  197. strBIOSVersion = strVersion;
  198. else
  199. strBIOSVersion = TAG_UNKNOWN;
  200. }
  201. }
  202. var p = col1.item();
  203. var subArray = new Array(3);
  204. subArray[0] = p.Manufacturer;
  205. subArray[1] = p.Model;
  206. subArray[2] = strBIOSVersion;
  207. mainArray[0] = 1;
  208. mainArray[1] = subArray;
  209. }
  210. displayTableSegment("Mark1", mainArray);
  211. }
  212. function getProcessorInfo() {
  213. var locator = wbemlocator;
  214. var service = locator.ConnectServer(remoteServer);
  215. service.Security_.impersonationlevel = 3;
  216. var col1 = new Enumerator(service.ExecQuery("Select * from Win32_Processor"));
  217. var i=0;
  218. var mainArray = new Array();
  219. for (;!col1.atEnd();col1.moveNext())
  220. {
  221. var p = col1.item();
  222. var subArray = new Array(3);
  223. subArray[0] = p.Name;
  224. subArray[1] = p.MaxClockSpeed ? (p.MaxClockSpeed + " " + TAG_MHZ) : TAG_UNKNOWN;
  225. subArray[2] = p.Description;
  226. i += 1;
  227. mainArray[0] = i;
  228. mainArray[i] = subArray;
  229. }
  230. displayTableSegment("Mark2", mainArray);
  231. }
  232. function getOSInfo() {
  233. var locator = wbemlocator;
  234. var service = locator.ConnectServer(remoteServer);
  235. service.Security_.impersonationlevel = 3;
  236. var nRemainingGracePeriod = null;
  237. var collData = new Enumerator(service.ExecQuery("Select * from Win32_WindowsProductActivation"))
  238. if(!collData.atEnd())
  239. {
  240. var data = collData.item();
  241. if(data.ActivationRequired > 0)
  242. nRemainingGracePeriod = data.RemainingGracePeriod;
  243. }
  244. var coll = new Enumerator(service.ExecQuery("Select * from win32_OperatingSystem"));
  245. var i=0;
  246. mainArray = new Array();
  247. for (;!coll.atEnd();coll.moveNext())
  248. {
  249. var p = coll.item();
  250. var subArray = new Array(6);
  251. subArray[0] = p.Caption;
  252. subArray[1] = nRemainingGracePeriod ? " - " + TAG_ACTIVATINSTATUS.replace(/%arg1%/, nRemainingGracePeriod) : "";
  253. subArray[2] = p.Version ;
  254. subArray[3] = (p.ServicePackMajorVersion).toString() + "." + (p.ServicePackMinorVersion).toString() ;
  255. subArray[4] = p.WindowsDirectory;
  256. var strHotFixID = "";
  257. var col1 = new Enumerator(service.ExecQuery("Select * from win32_QuickFixEngineering"));
  258. for (;!col1.atEnd();col1.moveNext())
  259. {
  260. var q= col1.item();
  261. strHotFixID = q.HotFixID;
  262. }
  263. var hndShell = new ActiveXObject("WScript.Shell");
  264. strPID = hndShell.RegRead("HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\ProductID");
  265. subArray[5] = strPID ;
  266. subArray[6] = strHotFixID;
  267. i += 1;
  268. mainArray[0] = i;
  269. mainArray[i] = subArray;
  270. break;
  271. }
  272. displayTableSegment("Mark3", mainArray);
  273. }
  274. function getGeneralInfo()
  275. {
  276. var locator = wbemlocator;
  277. try {
  278. var service = locator.ConnectServer(remoteServer, "root/cimv2/applications/MicrosoftIE");
  279. service.Security_.impersonationlevel = 3;
  280. var lanSettings = new Enumerator(service.ExecQuery("Select * from MicrosoftIE_LanSettings"));
  281. var strProxyServer="";
  282. for(;!lanSettings.atEnd();lanSettings.moveNext())
  283. {
  284. var lanSetting = lanSettings.item();
  285. strProxyServer = lanSetting.ProxyServer;
  286. if ((lanSetting.AutoProxyDetectMode).toUpperCase() == "ENABLED")
  287. strProxyServer = TAG_PRXYAUTODETECT;
  288. else if (strProxyServer == "")
  289. strProxyServer = TAG_NONE;
  290. }
  291. }
  292. catch(e) {
  293. strProxyServer = TAG_UNKNOWN;
  294. }
  295. service = locator.ConnectServer(remoteServer);
  296. service.Security_.impersonationlevel = 3;
  297. var col2 = new Enumerator(service.ExecQuery("Select * from win32_TimeZone"));
  298. var strTimeZone = "";
  299. var colCS = new Enumerator(service.ExecQuery("Select DaylightInEffect from Win32_ComputerSystem"));
  300. var daylightsavings = false;
  301. for (;!colCS.atEnd();colCS.moveNext())
  302. {
  303. var itm = colCS.item();
  304. daylightsavings = itm.DaylightInEffect
  305. }
  306. for (;!col2.atEnd();col2.moveNext())
  307. {
  308. var p = col2.item();
  309. if (daylightsavings)
  310. {
  311. strTimeZone = p.DaylightName;
  312. }
  313. else
  314. {
  315. strTimeZone = p.StandardName;
  316. }
  317. break;
  318. }
  319. /*var col3 = new Enumerator(service.ExecQuery("Select * from win32_OperatingSystem"));
  320. var strCountry = "";
  321. for (;!col3.atEnd();col3.moveNext())
  322. {
  323. var p = col3.item();
  324. strCountry = getCountryInfo(p.CountryCode);
  325. break;
  326. }*/
  327. var col4 = new Enumerator(service.ExecQuery("select * from Win32_NetworkAdapterConfiguration where IPEnabled = 'True'"));
  328. var strIPAddress = "";
  329. for (;!col4.atEnd();col4.moveNext())
  330. {
  331. var p = col4.item();
  332. if (p.IPAddress != null) {
  333. var temparr = (p.IPAddress).toArray();
  334. for (var ii=0; ii < temparr.length; ii++) {
  335. if ((temparr[ii] != null) || (temparr[ii] != ""))
  336. strIPAddress += (strIPAddress == "" ? "" : "<BR>") + temparr[ii];
  337. }
  338. }
  339. }
  340. var col4 = new Enumerator(service.ExecQuery("select * from Win32_NetworkAdapterConfiguration where IPXEnabled = 'True'"));
  341. var strIPXAddress = "";
  342. for (;!col4.atEnd();col4.moveNext())
  343. {
  344. var p = col4.item();
  345. if (p.IPXAddress != null)
  346. strIPXAddress += (strIPXAddress == "" ? "" : "<BR>") + p.IPXAddress;
  347. }
  348. strIPXAddress = (strIPXAddress == "") ? TAG_NOTENABLED : strIPXAddress;
  349. var coll = new Enumerator(service.ExecQuery("Select * from win32_ComputerSystem"));
  350. var i=0;
  351. mainArray = new Array();
  352. for (;!coll.atEnd();coll.moveNext())
  353. {
  354. var p = coll.item();
  355. var subArray = new Array(6);
  356. subArray[0] = p.Caption ;
  357. subArray[1] = p.Domain ;
  358. subArray[2] = strTimeZone ;
  359. subArray[3] = getNetworkInfo(p.DomainRole) ;
  360. subArray[4] = strProxyServer;
  361. subArray[5] = strIPAddress;
  362. subArray[6] = strIPXAddress;
  363. i += 1;
  364. mainArray[0] = i;
  365. mainArray[i] = subArray;
  366. break;
  367. }
  368. displayTableSegment("Mark4", mainArray);
  369. }
  370. function getMemoryInfo()
  371. {
  372. var locator = wbemlocator;
  373. var service = locator.ConnectServer(remoteServer);
  374. service.Security_.impersonationlevel = 3;
  375. var coll = new Enumerator(service.ExecQuery("Select Capacity from Win32_PhysicalMemory"));
  376. var memCapacity = null;
  377. mainArray = new Array();
  378. if (!coll.atEnd())
  379. {
  380. for (;!coll.atEnd();coll.moveNext())
  381. {
  382. var p = coll.item();
  383. if(!isNaN(p.Capacity))
  384. memCapacity += parseInt(p.Capacity); //in bytes.
  385. }
  386. }
  387. else
  388. {
  389. var insts = new Enumerator(service.ExecQuery("Select * from Win32_ComputerSystem"));
  390. for(; !insts.atEnd(); insts.moveNext())
  391. {
  392. var inst = insts.item();
  393. memCapacity += parseInt(inst.TotalPhysicalMemory); //in bytes.
  394. }
  395. }
  396. var subArray = new Array(1);
  397. subArray[0] = memCapacity ? fig2Words(memCapacity) : TAG_UNKNOWN;
  398. mainArray[0] = 1;
  399. mainArray[1] = subArray;
  400. displayTableSegment("Mark5", mainArray);
  401. }
  402. function displayTotalLogicalDrivesInfo()
  403. {
  404. var img1 = new Image();
  405. img1.src = "Graphics\\PieChart.gif";
  406. var locator = wbemlocator;
  407. var service = locator.ConnectServer(remoteServer);
  408. service.Security_.impersonationlevel = 3;
  409. var coll = new Enumerator(service.ExecQuery("Select * from win32_LogicalDisk"));
  410. var i=0;
  411. mainArray = new Array();
  412. var nTotalCapacity = 0;
  413. var strDrives = "";
  414. var nUsedSpace = 0;
  415. var nFreeSpace = 0;
  416. for (;!coll.atEnd();coll.moveNext())
  417. {
  418. var p = coll.item();
  419. if (p.DriveType == 3)
  420. {
  421. nTotalCapacity += Number(p.Size);
  422. strDrives += (p.Name + " ");
  423. nUsedSpace += Number(p.size - p.FreeSpace);
  424. nFreeSpace += Number(p.FreeSpace);
  425. }
  426. }
  427. // fill up main/sub array here
  428. var subArray = new Array(4);
  429. subArray[0] = fig2Words(nTotalCapacity) ;
  430. subArray[1] = strDrives ;
  431. var nPerUsage = Math.round(nUsedSpace/(nUsedSpace + nFreeSpace) * 100);
  432. nPerUsage = isNaN(nPerUsage) ? 0 : nPerUsage;
  433. var nGifID = determineRange(nPerUsage);
  434. var strGifPath = "Graphics\\33x16pie\\" + nGifID + "_chart.gif";
  435. subArray[2] = "<IMG Border=0 SRC=" + strGifPath + ">";
  436. subArray[3] = fig2Words(nUsedSpace) ;//used space
  437. subArray[4] = fig2Wordsfloor(nFreeSpace) ;
  438. i += 1;
  439. mainArray[0] = i;
  440. mainArray[i] = subArray;
  441. displayTableSegment("Mark6", mainArray);
  442. }