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.

345 lines
9.3 KiB

  1. //traverse the list and invoke display on each item.
  2. function displayTableSegment(outerDiv, head) {
  3. var strMsg = "<table width=\"100%\" cellspacing=0 cellpadding=0><tr class=\"sys-table-cell-bgcolor2 sys-font-body sys-color-body\"><td align='left' style=\"padding : 0.5em;\">%arg1%</td></tr></table>";
  4. var cnt = 1;
  5. var strHTML = "";
  6. var tableElement = null;
  7. if (document.all[outerDiv].length == null)
  8. tableElement = document.all[outerDiv];
  9. else
  10. tableElement = document.all[outerDiv][0];
  11. if (head==null)
  12. tableElement.outerHTML = strMsg.replace(/%arg1%/, TAG_NONE);
  13. else
  14. {
  15. var curr = head;
  16. while (curr!=null) {
  17. if (document.all[outerDiv].length == null)
  18. tableElement = document.all[outerDiv];
  19. else
  20. tableElement = document.all[outerDiv][0];
  21. if (cnt%2 == 0) {
  22. if (tableElement.all["tr_" + outerDiv])
  23. tableElement.all["tr_" + outerDiv].className = "sys-table-cell-bgcolor1";
  24. cnt = 1;
  25. }
  26. else {
  27. if (tableElement.all["tr_" + outerDiv])
  28. tableElement.all["tr_" + outerDiv].className = "sys-table-cell-bgcolor2";
  29. cnt++;
  30. }
  31. curr.show(tableElement);
  32. strHTML += tableElement.outerHTML;
  33. curr = curr.getNext();
  34. }
  35. tableElement.outerHTML = strHTML;
  36. }
  37. }
  38. //////////////////////
  39. //MySoftwareItem
  40. function mySoftwareItemSetValues(name, pid) {
  41. this.m_name = name;
  42. this.m_pid = pid;
  43. }
  44. function mySoftwareItemShow(tableElement) {
  45. tableElement.all["name"].innerHTML = this.m_name;
  46. tableElement.all["pid"].innerHTML = this.m_pid;
  47. }
  48. function mySoftwareItem() {
  49. //private
  50. this.m_name = null;
  51. this.m_pid = null;
  52. this.m_next = null;
  53. //public
  54. this.setNext = new Function("ptr", "this.m_next = ptr;");
  55. this.getNext = new Function("return this.m_next;");
  56. this.setValues = mySoftwareItemSetValues;
  57. this.show = mySoftwareItemShow;
  58. }
  59. //EO MySoftwareItem
  60. //////////////////////
  61. //////////////////////
  62. //MySoftware
  63. function mySoftwareShow() {
  64. displayTableSegment("softwarems", this.m_head);
  65. }
  66. function mySoftware() {
  67. //private
  68. this.m_head = null;
  69. //public
  70. this.show = mySoftwareShow;
  71. var mspidInfo = new ActiveXObject("MSPIDInfo.MSPID");
  72. var safearr = new VBArray(mspidInfo.GetPIDInfo(remoteServer));
  73. //safearr has one dimension
  74. for(i=0; i<=safearr.ubound(1); i+=2)
  75. {
  76. var oSoftwareItem = new mySoftwareItem();
  77. oSoftwareItem.setValues(safearr.getItem(i), safearr.getItem(i+1));
  78. oSoftwareItem.setNext(this.m_head); //add before
  79. this.m_head = oSoftwareItem;
  80. }
  81. }
  82. //EO MySoftware
  83. //////////////////////
  84. //////////////////////
  85. //MyStartupGrItem
  86. function myStartupGrItemSetValues(name, installDt) {
  87. this.m_name = name;
  88. this.m_installDate = installDt;
  89. }
  90. function myStartupGrItemShow(tableElement) {
  91. tableElement.all["name"].innerHTML = this.m_name;
  92. tableElement.all["installDate"].innerHTML = this.m_installDate;
  93. }
  94. //constructor
  95. function myStartupGrItem() {
  96. //private
  97. this.m_name = null;
  98. this.m_installDate = null;
  99. this.m_next = null;
  100. //public
  101. this.getName = new Function("return this.m_name;");
  102. this.setNext = new Function("ptr", "this.m_next = ptr;");
  103. this.getNext = new Function("return this.m_next;");
  104. this.setValues = myStartupGrItemSetValues;
  105. this.show = myStartupGrItemShow;
  106. }
  107. //EO myStartupGrItem
  108. //////////////////////
  109. //////////////////////
  110. //MyStartupGrItems
  111. function myStartupGrItemsShow() {
  112. displayTableSegment("startupGr", this.m_head);
  113. }
  114. function Populate(user, svcs)
  115. {
  116. strQuery = "select * from Win32_StartupCommand";
  117. var colFiles = new Enumerator(svcs.ExecQuery(strQuery));
  118. for(; !colFiles.atEnd(); colFiles.moveNext())
  119. {
  120. var fileInst = colFiles.item();
  121. if (fileInst.Command != "desktop.ini" && ( fileInst.User == user || fileInst.User == "All Users" || fileInst.User == ".DEFAULT"))
  122. {
  123. strCommand = fileInst.Command;
  124. //expand backslashes
  125. strCommand = strCommand.replace(/\\/g, "\\\\");
  126. //now clean up spaces such as command line arguments, but not spaces in path, like Program Files
  127. if (strCommand.indexOf("\"",0) == -1) //we have non-quoted path, quoted paths will likely contain spaces
  128. {
  129. var arrCmd = strCommand.split(" ");
  130. strCommand = arrCmd[0];
  131. }
  132. else
  133. {
  134. //split according to quotes (remove command line parameters assuming they're outside quotes
  135. var arrCmd = strCommand.split("\"");
  136. strCommand = arrCmd[1];
  137. }
  138. var arrName = fileInst.Command.split("\\");
  139. strQuery = "Select * from Cim_DataFile where Name = \"" + strCommand + "\"";
  140. var colItems = new Enumerator(svcs.ExecQuery(strQuery));
  141. if (colItems.atEnd())//for some reason WMI didn't return information for this item...
  142. {
  143. var oStartupGrItem = new myStartupGrItem();
  144. oStartupGrItem.setValues(fileInst.Name,TAG_UNKNOWN);
  145. oStartupGrItem.setNext(this.m_head); //add before
  146. this.m_head = oStartupGrItem;
  147. }
  148. else
  149. {
  150. for(; !colItems.atEnd(); colItems.moveNext())
  151. {
  152. var inst = colItems.item();
  153. var oStartupGrItem = new myStartupGrItem();
  154. oStartupGrItem.setValues(fileInst.Name, getDateTime(inst.InstallDate));
  155. oStartupGrItem.setNext(this.m_head); //add before
  156. this.m_head = oStartupGrItem;
  157. }
  158. }
  159. }
  160. }
  161. }
  162. //constructor
  163. function myStartupGrItems() {
  164. //private
  165. this.m_head = null;
  166. this.populate = Populate;
  167. //public
  168. this.show = myStartupGrItemsShow;
  169. var loc = wbemlocator;
  170. var svcs = loc.ConnectServer(remoteServer);
  171. svcs.Security_.impersonationlevel = wbemImpersonationLevelImpersonate;
  172. var strQuery = "Select * From Win32_ComputerSystem";
  173. var colCompSys = new Enumerator(svcs.ExecQuery(strQuery));
  174. if (!colCompSys.atEnd())
  175. {
  176. var compSys = colCompSys.item();
  177. if(compSys.UserName)
  178. this.populate(compSys.UserName, svcs);
  179. }
  180. }
  181. //EO MyStartupGrItems
  182. //////////////////////
  183. //////////////////////
  184. //MyLogEntry
  185. function myLogEntryShow(tableElement) {
  186. tableElement.all["datetime"].innerHTML = this.m_datetime;
  187. tableElement.all["desc"].innerHTML = this.m_desc;
  188. }
  189. function myLogEntry(timeGenerated, msg) {
  190. this.m_datetime = getDateTime(timeGenerated);
  191. this.m_desc = msg;
  192. this.m_next = null;
  193. this.setNext = new Function("ptr", "this.m_next = ptr;");
  194. this.getNext = new Function("return this.m_next;");
  195. this.show = myLogEntryShow;
  196. }
  197. //EO MyLogEntry
  198. //////////////////////
  199. //////////////////////
  200. //MyLog
  201. function myLogShow() {
  202. displayTableSegment("log", this.m_head);
  203. }
  204. function myLog() {
  205. this.m_head = null;
  206. this.show = myLogShow;
  207. var loc = wbemlocator;
  208. var svcs = loc.ConnectServer(remoteServer);
  209. svcs.Security_.impersonationlevel = wbemImpersonationLevelImpersonate;
  210. var strQuery = "Select TimeGenerated, Message From Win32_NTLogEvent Where SourceName = 'DrWatson'";
  211. var colItems = new Enumerator(svcs.ExecQuery(strQuery));
  212. for(; !colItems.atEnd(); colItems.moveNext())
  213. {
  214. var inst = colItems.item();
  215. with (inst)
  216. {
  217. var oLogEntry = new myLogEntry(TimeGenerated, Message);
  218. }
  219. oLogEntry.setNext(this.m_head); //add before
  220. this.m_head = oLogEntry;
  221. }
  222. }
  223. //EO MyLog
  224. //////////////////////
  225. function DisplayLocStrings() {
  226. WaitMessage.innerHTML = MSG_WAIT;
  227. Refresh.innerHTML = TAG_REFRESH;
  228. with(Registered_Software.all) {
  229. Caption.innerHTML = TAG_SOFTWARE;
  230. Col1.innerHTML = TAG_REGSOFTWARE;
  231. Col2.innerHTML = TAG_PRODUCTIDENTIFICATION;
  232. }
  233. with(Startup_Program_Group.all) {
  234. Caption.innerHTML = TAG_STARTPROGGR;
  235. Col1.innerHTML = TAG_SOFTWARE;
  236. Col2.innerHTML = TAG_INSTALLDATE;
  237. }
  238. with(DrWatsonLog.all) {
  239. Caption.innerHTML = TAG_WATSONLOGCAPTION;
  240. Col1.innerHTML = TAG_DATETIME;
  241. Col2.innerHTML = TAG_DESCRIPTION;
  242. }
  243. }
  244. var INCR_UNIT = 100/3;//move progress bar in increments of INCR_UNIT
  245. function LoadChores(taskId) {
  246. try {
  247. switch(taskId)
  248. {
  249. case 0:
  250. remoteServer = ShowServerName(TAG_SOFTWARE);
  251. break;
  252. case 1:
  253. DrawProgressBar(INCR_UNIT, TAG_SOFTWARE);
  254. break;
  255. case 2:
  256. var oSoftware = new mySoftware(); //Installed MS Software
  257. oSoftware.show();
  258. break;
  259. case 3:
  260. DrawProgressBar(INCR_UNIT * 2, TAG_STARTPROGGR);
  261. break;
  262. case 4:
  263. var oStartupGrItems = new myStartupGrItems; //Startup Logical Program Gr
  264. oStartupGrItems.show();
  265. break;
  266. case 5:
  267. DrawProgressBar(INCR_UNIT * 3, TAG_WATSONLOG);
  268. break;
  269. case 6:
  270. var oLog = new myLog; //Dr Watson Log
  271. oLog.show();
  272. break;
  273. default:
  274. taskId = -1;
  275. _header.style.display = "none";
  276. _data.style.display = "";
  277. _body.style.cursor= "default";
  278. _body.scroll= "auto";
  279. }
  280. if(taskId >= 0)
  281. window.setTimeout("LoadChores(" + ++taskId + ")", TIMEOUT);
  282. }
  283. catch (e) {
  284. HandleErr(e);
  285. }
  286. }
  287. function dispatchFunction() {
  288. _body.style.cursor= "wait";
  289. _body.scroll= "no";
  290. DisplayLocStrings();
  291. SetProgressBarImage();
  292. window.setTimeout("LoadChores(0)", TIMEOUT);
  293. }