Author Topic: какая есть команда чтобы убить процесс?  (Read 5513 times)

0 Members and 1 Guest are viewing this topic.

Alladar

  • Guest
Нужно убить процесс с консоли, причём чтобы работало на разных ОС семейства Windows.
 
  Можно это как-то сделать?

Offline Diman

  • Sr. Member
  • ****
  • Posts: 366
  • Karma: +0/-0
    • http://localhost/
net stop <service> - это сервис, а процесс не знаю
Жизнь - это игpа в реальном времени. Сюжет хреновый, сохраняться нельзя, зато гpафика - просто отпад...

Alladar

  • Guest
Мне бы процесс..

Offline Egor

  • Sr. Member
  • ****
  • Posts: 251
  • Karma: +0/-0
PsKill.
Quote
Windows NT/2000 does not come with a command-line 'kill' utility. You can get one in the Windows NT or Win2K Resource Kit, but the kit's utility can only terminate processes on the local computer. PsKill is a kill utility that not only does what the Resource Kit's version does, but can also kill processes on remote systems. You don't even have to install a client on the target computer to use PsKill to terminate a remote process.
« Last Edit: August 19, 2005, 14:53:44 by Egor »

Alladar

  • Guest
Мне не с помощью доп. программ нужно. Мне в uninstall нужно команду добавить которая бы кикала требуемый процесс,. без доп. программ.. с помощью стандартных средств винды никак?

Offline Egor

  • Sr. Member
  • ****
  • Posts: 251
  • Karma: +0/-0
Никак.

Offline jack

  • Full Member
  • ***
  • Posts: 218
  • Karma: +0/-1
    • http://
Quote
Никак.
[snapback]3697[/snapback]
почему это никак?

\MSHelp\WIN32SDK.HLP :
Code: [Select]
Implementing a "Kill" Operation in Windows NT

PSS ID Number: Q90749

Authored 21-Oct-1992   Last modified 02-Mar-1995

The information in this article applies to:

 - Microsoft Win32 Software Development Kit (SDK) for Windows NT
   version 3.1


SUMMARY

The following sample demonstrates how to implement a "kill" operation, such
as a UNIX ps/kill, under Windows NT. Note that PView will give you the PID
you need.

The code sample makes use of the Win32 API TerminateProcess(). While
TerminateProcess() does clean up the objects owned by the process, it does
not notify any DLLs hooked to the process. Therefore, one can easily leave
the DLL in an unstable state.

In general, the Task List is a much cleaner method of killing processes.

MORE INFORMATION

The following sample shows how to "kill" a process, given its process ID
(PID).

Sample Code
-----------

#include <windows.h>
#include <stdio.h>

void ErrorOut(char errstring[30])
/*
Purpose: Print out an meaningful error code by means of
         GetLastError and printf.

Inputs:  errstring - the action that failed, passed by the
                     calling proc.

Returns: none

Calls:   GetLastError
*/

{
   DWORD Error;

   Error= GetLastError();

   printf("Error on %s = %d\n", errstring, Error);
}


void main(int argc, char *argv[])
{
   HANDLE hProcess;
   DWORD ProcId;
   BOOL TermSucc;

   if (argc == 2)
   {
      sscanf(agrv[1],"%x", &ProcId);
      hProcess= OpenProcess(PROCESS_ALL_ACCESS, TRUE, ProcId);
      if (hProcess == NULL)
         ErrorOut("OpenProcess");
      TermSucc= TerminateProcess(hProcess, 0);
      if (TermSucc == FALSE)
         ErrorOut("TerminateProcess");
      else

         printf("Process# %.0lx terminated successfully!\n", ProcId);
   }
   else
   {
      printf("\nKills an active Process\n");
      printf("Usage: killproc ProcessID\n");
   }
}

Additional reference words: 3.10
KBCategory: kbprg
KBSubcategory: BseProcThrd

Alladar

  • Guest
Эмм.. и как это в консольку запихать?)

 Вставил в дистриб pskill, правда дополнительные 100кбайт ..

Offline Egor

  • Sr. Member
  • ****
  • Posts: 251
  • Karma: +0/-0
Quote
почему это никак?
[snapback]3698[/snapback]
Потому что нужно внимательнее читать тему.

Offline jack

  • Full Member
  • ***
  • Posts: 218
  • Karma: +0/-1
    • http://
Quote
Эмм.. и как это в консольку запихать?)
написать тулзу :)

Alladar

  • Guest
какая есть команда чтобы убить процесс?
« Reply #10 on: August 22, 2005, 16:25:43 »
Quote
написать тулзу :)
[snapback]3710[/snapback]

 Я предпочел скачать  :)