473,398 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Terminate a process by specifing computer name using PERL..

40
Hi.,

I am using the following code to terminate the any process by giving the process name as input...

Expand|Select|Wrap|Line Numbers
  1. use Win32::Process::List;
  2. use Win32::OLE;
  3. $Win32::OLE::Warn = 3;
  4. $P = Win32::Process::List->new();
  5. print "Enter the process name.exe to terminate:  ";
  6. $name=<STDIN>;
  7. chomp ($name);
  8.  
  9. %list = $P->GetProcesses();
  10. foreach  $key (keys %list) 
  11. {
  12.     #$name = "regedit.exe";
  13.     $ss = $list{$key};
  14.     if(($ss eq $name))
  15.     {
  16.         $pid=$key;
  17.     }
  18. }
  19. $strComputer = '.';
  20. $intPID=$pid;
  21. print " Process PID: $intPID\n";
  22. $objWMIProcess = Win32::OLE->GetObject('winmgmts:\\\\' . $strComputer . '\\root\\cimv2:Win32_Process.Handle=\'' . $intPID . '\'');
  23. print 'Process name: ' . $objWMIProcess->Name, "\n";
  24. $intRC = $objWMIProcess->Terminate();
  25.  
  26.  
If I run the above script in server., I am in trouble by terminate the process by specifying computer name.. if one or more users using the same application

kindly anyone help me regarding this problem...
Dec 20 '07 #1
2 2488
numberwhun
3,509 Expert Mod 2GB
Hi.,

I am using the following code to terminate the any process by giving the process name as input...

Expand|Select|Wrap|Line Numbers
  1. use Win32::Process::List;
  2. use Win32::OLE;
  3. $Win32::OLE::Warn = 3;
  4. $P = Win32::Process::List->new();
  5. print "Enter the process name.exe to terminate:  ";
  6. $name=<STDIN>;
  7. chomp ($name);
  8.  
  9. %list = $P->GetProcesses();
  10. foreach  $key (keys %list) 
  11. {
  12.     #$name = "regedit.exe";
  13.     $ss = $list{$key};
  14.     if(($ss eq $name))
  15.     {
  16.         $pid=$key;
  17.     }
  18. }
  19. $strComputer = '.';
  20. $intPID=$pid;
  21. print " Process PID: $intPID\n";
  22. $objWMIProcess = Win32::OLE->GetObject('winmgmts:\\\\' . $strComputer . '\\root\\cimv2:Win32_Process.Handle=\'' . $intPID . '\'');
  23. print 'Process name: ' . $objWMIProcess->Name, "\n";
  24. $intRC = $objWMIProcess->Terminate();
  25.  
  26.  
If I run the above script in server., I am in trouble by terminate the process by specifying computer name.. if one or more users using the same application

kindly anyone help me regarding this problem...
Ok, this is your friendly reminder before the warning. When posting code in the forums, please remember to surround the code in the necessary, required code tags.

Thank you!

Regards,

Jeff
Dec 20 '07 #2
cnsabar
40
Hi Jeff,,

I am new in this forum site..
I will use the code tags in future...

Thanks.
Dec 20 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: RL | last post by:
Hello Perl gurus, 1. I have a web page where I can push a button (dospawn.html). 2. This button calls a CGI script (spawnboss.cgi) 3. spawnboss.cgi calls a forking perl script (forkme.pl) 4....
7
by: Andrew S. Giles | last post by:
Hello, I am looking for an article, or some information about how to get a C# windows forms application to trap the "End Process" event from the Task Manager? Is such a thing possible, and if...
3
by: Keith Grefski | last post by:
I cant seem to figure out how to terminate a process in vb.net i can do it using vbscript and wmi but terminate doesnt seem to exist in the available classes for wmi under vb.net
23
by: Xah Lee | last post by:
The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations Xah Lee, 2006-03-15 Let me summarize: The LISP notation, is a functional notation, and is not a...
2
by: R. Nachtsturm | last post by:
Hi, i have the problem that when i create a low priority background thread, start it, and wait for it to finish that it does not seem to terminate even after it is finished.. if i use...
16
by: eflatunn | last post by:
Hi all, my problem is that the application doesn't terminate when I close the form using the close box on the caption bar. Actually it seems as if the program is closed but task manager's process...
0
by: cnsabar | last post by:
Hi., I need a Perl script to terminate the any running process in server. by specifying computer name and process name.. I have the following code to terminate the any process by specifying...
1
by: thunder54007 | last post by:
hi, here is my script: import win32con import time import wmi c = wmi.WMI() for process in c.Win32_Process(name = "notepad.exe"): print process.ProcessId, process.Name process.Terminate ()
5
by: cnsabar | last post by:
Hi., I want to call some function when the user force to terminate the perl program. For example., I write a program to create a file when the program starts... Also I need to delete a file...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.