ASP. NET can be used to remotely kill useless processes. The following code lists all active processes and then kills them. Note that this file should be placed in a virtual directory with Administrator access permissions.
The following code is C:
<HTML> <HEAD> <% @ Import namespace = "System. Diagnostics" %> <Script language = "C #" runat = "Server" debug = "true"> Void Page_Load (Object Sender, EventArgs e ){ BtnKill. Attributes. Add ("onclick", "javascript: return confirm ('Do you really want to kill this process? ');"); } Private void KillProcess (string processName ){ System. Diagnostics. Process myproc = new System. Diagnostics. Process (); // Obtain all opened Processes Try { Foreach (Process thisproc in Process. GetProcessesByName (processName )){ If (! Thisproc. CloseMainWindow ()){ Thisproc. Kill (); } } } Catch (Exception Exc) { Msg. Text + = "Killing" + procname. SelectedItem. Text + "failed! "; } } Public void btnKill_Click (object sender, System. EventArgs e) { KillProcess (procname. SelectedItem. Text ); Msg. Text = procname. SelectedItem. Text + "has been killed. "; } Public void btnShow_Click (object sender, System. EventArgs e ){ ArrayList procList = new ArrayList (); String tempName = ""; Int begpos; Int endpos; Foreach (Process thisProc in System. Diagnostics. Process. GetProcesses ()){ TempName = thisProc. ToString (); Begpos = tempName. IndexOf ("(") + 1; Endpos = tempName. IndexOf (")"); TempName = tempName. Substring (begpos, endpos-begpos ); ProcList. Add (tempName ); } Procname. DataSource = procList; Procname. DataBind (); } </Script> </HEAD> <Body> <Basefont Face = "Tahoma"/> <Center> <Table cellspacing = 2 cellpadding = 2 border = 0 BGCOLOR = "# fFCC66"> <Form id = "frmProc" runat = "Server" method = "post"> <TR> <TD> <ASP: DropDownList id = "procname" runat = "server"/> </TD> <TD> Process name </TD> </TR> <TR> <TD> <Asp: button id = "btnKill" Text = "Kill process" runat = "server" CausesValidation = "False" onclick = "btnKill_Click"/> </TD> <TD> <asp: button id = "btnShow" Text = "list all processes" runat = "server" CausesValidation = "False" onclick = "btnShow_Click"/> </TD> </TR> </TABLE> <Center> <asp: Label id = "msg" runat = "server"/> </center> </Form> </Center> </Body> </HTML> |