Board logo

标题: VBS版系统进程控制程序 [打印本页]

作者: youxi01    时间: 2007-11-5 20:00     标题: VBS版系统进程控制程序

  1. <!--////////程序说明/////////====
  2. 程序名称:系统进程控制程序
  3. 初期作品....
  4. 作者说明:youxi01,,,版权没有,欢迎盗版!!///////////-->
  5. <TITLE>程序设置</TITLE>
  6. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  7. <HTA:APPLICATION
  8. ID="MyhyliApp"
  9. APPLICATIONNAME="设置程序"
  10. VERSION="1.0"
  11. SCROLL="no"
  12. INNERBORDER="no"
  13. CONTEXTMENU="no"
  14. CAPTION="yes"
  15. SHOWINTASKBAR="yes"
  16. SINGLEINSTANCE="yes"
  17. SYSMENU="yes"
  18. WINDOWSTATE="normal"
  19. NAVIGABLE="yes"
  20. />
  21. <script>
  22. <!--
  23. var curMenu=null;
  24. function initializeUI() {
  25. var i;
  26. for(i=0;i<document.all.tags('span').length;i++) {
  27. if(document.all.tags('span')[i].className=='menuUp') {
  28.   document.all.tags('span')[i].attachEvent("onmouseover", onmenuOver);
  29.   document.all.tags('span')[i].attachEvent("onmouseout", onmenuOut);
  30.   document.all.tags('span')[i].attachEvent("onmousedown", onmenuDown);
  31.   }
  32. }
  33. }
  34. function onmenuOver() {
  35. obj=event.srcElement;
  36. obj.className='menuOver';
  37. if(curMenu!=null && eval('sub'+curMenu.id+'.style.visibility=="visible"')) {
  38. curMenu.className='menuUp';
  39. obj.className='menuDown';
  40. eval('sub'+curMenu.id+'.style.visibility="hidden"');
  41. eval('sub'+obj.id+'.style.visibility="visible"');
  42. eval('sub'+obj.id+'.runtimeStyle.left=sub'+obj.id+'.style.left');
  43. eval('sub'+obj.id+'.runtimeStyle.top=sub'+obj.id+'.style.top');
  44. curMenu=obj;
  45. }
  46. }
  47. function hideMenu() {
  48. if(curMenu!=null && event.srcElement.tagName!='SPAN') {
  49. curMenu.className='menuUp';
  50. eval('sub'+curMenu.id+'.style.visibility="hidden"');
  51. curMenu=null;
  52. }
  53. }
  54. function onmenuOut() {
  55. obj=event.srcElement;
  56. if(eval('sub'+obj.id+'.style.visibility!="visible"')) {
  57. obj.className='menuUp';
  58. }
  59. }
  60. function onmenuDown() {
  61. obj=event.srcElement;
  62. if(curMenu!=null && curMenu!=obj) {
  63. obj.className='menuDown';
  64. eval('sub'+obj.id+'.style.visibility="visible"');
  65. eval('sub'+obj.id+'.runtimeStyle.left=sub'+obj.id+'.style.left');
  66. eval('sub'+obj.id+'.runtimeStyle.top=sub'+obj.id+'.style.top');
  67. curMenu.className='menuUp';
  68. eval('sub'+curMenu.id+'.style.visibility="hidden"');
  69. }
  70. else if(curMenu==obj) {
  71. if(obj.className!='menuDown') {   
  72.   obj.className='menuDown';
  73.   eval('sub'+obj.id+'.style.visibility="visible"');
  74.   eval('sub'+obj.id+'.runtimeStyle.left=sub'+obj.id+'.style.left');
  75.   eval('sub'+obj.id+'.runtimeStyle.top=sub'+obj.id+'.style.top');
  76.   }
  77. else {
  78.   obj.className='menuUp';
  79.   eval('sub'+obj.id+'.style.visibility="hidden"');
  80.   }
  81. }
  82. else {
  83. obj.className='menuDown';
  84. eval('sub'+obj.id+'.style.visibility="visible"');
  85. eval('sub'+obj.id+'.runtimeStyle.left=sub'+obj.id+'.style.left');
  86. eval('sub'+obj.id+'.runtimeStyle.top=sub'+obj.id+'.style.top');
  87. }
  88. curMenu=obj;
  89. }
  90. function popupmenu() {
  91. curMenu=menu4;
  92. submenu4.runtimeStyle.pixelLeft=event.x;
  93. submenu4.runtimeStyle.pixelTop=event.y;
  94. submenu4.style.visibility='visible';
  95. }
  96. document.onclick=hideMenu;
  97. </script>
  98. <SCRIPT LANGUAGE="VBScript">
  99. dim owner(50),path(50),name(50),id(50),thread(50)
  100. Sub Window_onLoad   
  101.      initializeUI
  102.         window.resizeTo 400,250
  103.   window.moveTo 400,200
  104. End Sub
  105. sub getprocess()
  106. if process.options.length>1 then      '如果原来已经有项目,则移除所有项目;'
  107. for i=1 to process.options.length
  108. process.options.remove(1)
  109. next
  110. end if
  111. i=1
  112. Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")     '连接到WMI;'
  113. Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process")
  114. For each objProcess in colProcesses
  115.         Set objOption = Document.createElement("OPTION")  '添加option元素;'
  116.         objOption.Text = objProcess.name
  117.         objOption.Value = i
  118.   process.Add(objOption)     'process列表框添加项目;'
  119.   colProperties = objProcess.GetOwner(strNameOfUser,strUserDomain) '获取用户;'
  120.   name(i)=objProcess.Name     '用数组储存程序名称;'
  121.   id(i)=objProcess.ProcessID
  122.   thread(i)=objProcess.ThreadCount
  123.   owner(i)=strNameOfUser
  124.   path(i)=objProcess.ExecutablePath
  125.   i=i+1
  126. Next
  127. End sub
  128. sub getvalue()
  129. CurID=process.selectedindex
  130. read.value="进程名称:"&vbcrlf&name(CurID)&vbcrlf&"ID:"&id(CurID)&vbcrlf&"所有者:"&owner(CurID)
  131. read.value=read.value&vbcrlf & "线程数:"&vbcrlf&thread(CurID)&vbcrlf&"路径:"&vbcrlf&path(CurID)
  132. end sub
  133. sub killprocess()      '停止进程'
  134. if process.selectedindex<1 then            '如果没有选择进程,则退出函数;'
  135. exit sub
  136. end if
  137. prs=process.options(process.selectedindex).text    '进程名称为列表框中选择名称;'
  138. Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
  139. Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process where name='"&prs&"'")
  140. For each objProcess in colProcesses
  141. objProcess.Terminate()            '结束该进程。'
  142. next
  143. end sub
  144. sub about()
  145. txt="程序说明:"&vbcrlf&vbcrlf&"本程序基于以下技术开发"&vbcrlf&"-DHTML"&vbcrlf&"-HTML-Application"
  146. txt=txt&vbcrlf&"FileSystemObject(FSO)"&vbcrlf&vbcrlf&"系统要求"&vbcrlf&"Internet Explorer 5.5以上"
  147. txt=txt&vbcrlf&"WinXP/Win98/Win2000"&vbcrlf&vbcrlf &"2006-5-1"
  148. read.value=txt
  149. end sub
  150. sub delfile(s)
  151. CurID=process.selectedindex
  152. if process.options.length<=1 or CurID<1 then
  153. exit sub
  154. end if
  155. set fso=createobject("scripting.filesystemobject")
  156. objFile=path(CurID)      '获取文件名,文件路径'
  157. set myFile=fso.getfile(objFile)     '获得文件对象'
  158. if s="d" then
  159. remind=msgbox("将要删除文件:"&vbcrlf&myFile&vbcrlf&"您是否确定!",vbOKCancel+vbQuestion+vbDefaultButton2,"提醒消息")
  160.    if remind=1 then
  161.      killprocess()
  162.      myFile.delete
  163.    else
  164.      exit sub
  165.    end if
  166. else
  167. set myFolder=myFile.parentfolder   '取文件所在的文件夹;'
  168. set objShell=createobject("wscript.shell")
  169. objShell.run(myFolder)
  170. end if
  171. end sub
  172. </SCRIPT>
  173. <STYLE>
  174. body {
  175. margin:0px;
  176. background-color:menu;
  177. }
  178. td,a,div,textarea {
  179. font-family:宋体;
  180. font-size:12px;
  181. }
  182. .submenu {
  183. border:2px outset buttonhighlight;
  184. background-color:menu;
  185. position:absolute;
  186. top: 21px;
  187. z-index:13;
  188. padding:1px;
  189. overflow:hidden;
  190. visibility: hidden;
  191. }
  192. a.menutext {
  193. width:100%;
  194. color:menutext;
  195. text-decoration:none;
  196. padding:2px;
  197. }
  198. a.menutext:hover {
  199. background-color:#CCCCCC;
  200. color:#0066CC;
  201. border-top-color: #000000;
  202. border-right-color: #000000;
  203. border-bottom-color: #000000;
  204. border-left-color: #000000;
  205. }
  206. .menuUp {
  207. margin:1px 0px;
  208. padding-top:3px;
  209. padding-left:8px;
  210. padding-right:8px;
  211. border:1px solid menu;
  212. cursor:default;
  213. height:20px;
  214. position:relative;
  215. overflow: hidden;
  216. visibility: visible;
  217. }
  218. .menuOver {
  219. margin:1px 0px;
  220. padding-top:3px;
  221. padding-left:8px;
  222. padding-right:8px;
  223. border-left:1px solid buttonhighlight;
  224. border-top:1px solid buttonhighlight;
  225. border-right:1px solid buttonshadow;
  226. border-bottom:1px solid buttonshadow;
  227. height:20px;
  228. position:relative;
  229. }
  230. .menuDown {
  231. padding-top:4px;
  232. padding-left:9px;
  233. padding-right:7px;
  234. cursor:default;
  235. height:20px;
  236. position:relative;
  237. margin-top: 1px;
  238. margin-right: 0px;
  239. margin-bottom: 1px;
  240. margin-left: 0px;
  241. border-top-width: 1px;
  242. border-right-width: 1px;
  243. border-bottom-width: 1px;
  244. border-left-width: 1px;
  245. border-top-style: solid;
  246. border-right-style: solid;
  247. border-bottom-style: solid;
  248. border-left-style: solid;
  249. border-top-color: buttonshadow;
  250. border-right-color: buttonhighlight;
  251. border-bottom-color: buttonhighlight;
  252. border-left-color: buttonshadow;
  253. }
  254. .separator {
  255. width:100%;
  256. margin:2px;
  257. margin-top:-4px;
  258. height:12px;
  259. overflow:hidden;
  260. }
  261. .grid {
  262. width:9px;
  263. height:9px;
  264. font-size:1px;
  265. line-height:1px;
  266. border:1px solid black;
  267. vertical-align:absmiddle;
  268. }
  269. .en {
  270. font-family:Tahoma;
  271. font-size:11px;
  272. }
  273. #readingarea {
  274. width:100%;
  275. height:100%;
  276. background-color:#C0C0C0;
  277. color:#000000;
  278. font-size:14px;
  279. line-height:18px;
  280. letter-spacing:1px;
  281. padding:10px;
  282. }
  283. #process {
  284. width:100%;
  285. font-size:14px;
  286. font-family:Arial;
  287. }
  288. </STYLE>
  289. </HEAD>
  290. <BODY>
  291. <table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
  292.   <tr>
  293.     <td id=menubar onselectstart="return false" colspan="1">
  294. <span class="menuUp" id=menu1>文件</span><span class="menuUp" id=menu2>其它</span><span class="menuUp" id=menu3>帮助</span>   
  295. <div id="submenu4" class=submenu style="left: 140px; width:100px">
  296.   <a class="menutext" href=# title="刷新进程" onClick="getprocess()"> 刷新进程</a>
  297.   <a class="menutext" href=# title="结束进程" onClick="killprocess()"> 结束进程</a>
  298.   <div class="separator">
  299.       <hr>
  300.      </div>
  301.   <a class="menutext" href=# title="删除进程对应文件" onClick="delfile('d')"> 删除文件</a>
  302.   <a class="menutext" href=# title="转到程序所在的文件夹" onClick="delfile('r')"> 转到文件</a>
  303.         <div class="separator">
  304.           <hr>
  305.         </div>
  306.     <a class="menutext" href=# title="关于" onClick="about()"> 关于软件</a> </div>
  307. <td><span class="menuUp" id=menu4></span></td>
  308.   </tr>
  309.   <tr>
  310.     <td width="554" height="375" align="left" valign=top><textarea name="read" cols="" rows="" readonly wrap="virtual" id="readingarea" oncontextmenu="popupmenu()" >        系统进程管理
  311. 1、获取系统进程;
  312. 2、停止进程;
  313. 3、删除相关文件。</textarea></td>
  314.     <td width=233 valign=top id=directory onselectstart="return false"><p>
  315.       <select name="process" size=12 id=process  onclick="getvalue()" ondblclick="killprocess()">
  316.       <option selected>进程名称</option>
  317.         </select>
  318.   </p>    </td>
  319.   </tr>
  320. </table>
  321. <div id="submenu1" class=submenu style="left: 0px; width:120px">
  322. <a class="menutext" href="#" title="获取系统进程" onClick="getprocess()"> 获得进程</a>
  323. <a class="menutext" href=# title="停止系统进程" onClick="killprocess()"> 停止进程</a>
  324. <a class="menutext" href=# title="删除进程对应文件" onClick="delfile('d')"> 删除文件</a>
  325. <div class="separator"><hr></div>
  326. <a class="menutext" href=#  onClick="window.close()" title="退出程序"> 关闭  </span></a>
  327. </div>
  328. <div id="submenu2" class=submenu style="left: 42px; width:120px">
  329.     <a class="menutext" href=# title="课时安排查询"> 课时查询</a>
  330. <a class="menutext" href=# title="生日提醒"> 生日提醒</a>
  331. <div class="separator"><hr></div>
  332. <a class="menutext" href=# title="关闭计算机"> 关机</a>
  333. <a class="menutext" href=# title="重新启动计算机"> 重启</a>
  334. <a class="menutext" href=# title="注销"> 注销</a>
  335. </div>
  336. <div id="submenu3" class=submenu style="left: 84px; width:100px">
  337. <a class="menutext" href="mailto:pcl_83@163.com" title="联系作者"> 联系作者</a>
  338. <a class="menutext" href=# title="关于" onClick="about()"> 关于软件</a></div>
  339. </BODY>
  340. </HTML>
复制代码

作者: somebody    时间: 2007-11-5 22:08

好多代码........
不过获取不到进程...
作者: ibm    时间: 2008-10-5 21:15

楼主真牛,但我测试过,并不成功!




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2