KillProcess function
Moderators: Dorian (MJT support), JRL
KillProcess function
This is my code below doesnt work.
ProcessExists>PrintCtrl.exe,bNotepadExists
If>bNotepadExists=True
KillProcess>PrintCtrl.exe
Endif
ProcessExists>PrintDisp.exe,bNotepadExists
If>bNotepadExists=True
KillProcess>PrintDisp.exe
Endif
It seem the killprocess function can kill a notepad.exe process but not system process.
I didnt want to use a vbscript method or taskkill method.
Can the killprocess function be enhanced(more powerful) for killing process?
Thanks
ProcessExists>PrintCtrl.exe,bNotepadExists
If>bNotepadExists=True
KillProcess>PrintCtrl.exe
Endif
ProcessExists>PrintDisp.exe,bNotepadExists
If>bNotepadExists=True
KillProcess>PrintDisp.exe
Endif
It seem the killprocess function can kill a notepad.exe process but not system process.
I didnt want to use a vbscript method or taskkill method.
Can the killprocess function be enhanced(more powerful) for killing process?
Thanks
- Marcus Tettmar
- Site Admin
- Posts: 7391
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Maybe admin privs are required to kill this process. Try running Macro Scheduler as admin and then see if the script is able to kill the process.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: KillProcess function
PrintCtrl.exe is likely a Windows service.newuser wrote:ProcessExists>PrintCtrl.exe,bNotepadExists
If>bNotepadExists=True
KillProcess>PrintCtrl.exe
Endif
Not sure why you wish to terminate the printer control service.
Try:
Code: Select all
Run>NET STOP PrintCtrl
Its a pdf printer process not a service, I install a software from giveawayoftheday sometime ago which is from http://www.all2pdf.com. Although I could kill it using taskmanager,vbscript, taskkill but I cant kill it using macro scheduler killprocess function. It cross my mind whynot write a macro to kill it on startup for the fun of it.
But the problem is the killprocess function can kill a notepad, even a calculator process but not those 2 process. Why?
But the problem is the killprocess function can kill a notepad, even a calculator process but not those 2 process. Why?
KillProcess is a perfect killer, you're rest assured.newuser wrote:Its a pdf printer process not a service, I install a software from giveawayoftheday sometime ago which is from http://www.all2pdf.com. Although I could kill it using taskmanager,vbscript, taskkill but I cant kill it using macro scheduler killprocess function. It cross my mind whynot write a macro to kill it on startup for the fun of it.
But the problem is the killprocess function can kill a notepad, even a calculator process but not those 2 process. Why?
It seems to me both PrintCtrl.exe and PrintDisp.exe aren't processes.
If you actually watch the Windows Task Manager, PrintCtrl.exe and PrintDisp.exe are successfully killed by KillProcess, but restored seconds later.
Have you actually and successfully killed the both with taskmanager,vbscript, taskkill,...and other killers? Show us your script.
PrintCtrl.exe and PrintDisp.exe are installed as a Windows Service/Driver. Why do you want to kill them? I'm confounded.
Batch file
Wmic batch file
Vbscript file
Vbscript second version file
Autoit file
Code: Select all
taskkill /F /IM PrintCtrl.exe
taskkill /F /IM PrintDisp.exe
Code: Select all
wmic process where name="PrintCtrl.exe" call terminate
wmic process where name="PrintDisp.exe" call terminate
Code: Select all
Dim oShell : Set oShell = CreateObject("WScript.Shell")
oShell.Run "taskkill /f /im PrintCtrl.exe", , True
oShell.Run "taskkill /f /im PrintDisp.exe", , True
Code: Select all
Const strComputer = "."
Set WshShell = CreateObject("WScript.Shell")
Dim objWMIService, colProcessList
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'PrintCtrl.exe'")
For Each objProcess in colProcessList
WshShell.Exec "taskkill /F /IM " & objProcess.ProcessId
Next
Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'PrintDisp.exe'")
For Each objProcess in colProcessList
WshShell.Exec "taskkill /F /IM " & objProcess.ProcessId
Next
Code: Select all
ProcessClose("PrintCtrl.exe")
ProcessClose("PrintDisp.exe")
Thanks for your magnificent demo of process killers in multi-languages.newuser wrote:Batch fileWmic batch fileCode: Select all
taskkill /F /IM PrintCtrl.exe taskkill /F /IM PrintDisp.exe
Vbscript fileCode: Select all
wmic process where name="PrintCtrl.exe" call terminate wmic process where name="PrintDisp.exe" call terminate
Vbscript second version fileCode: Select all
Dim oShell : Set oShell = CreateObject("WScript.Shell") oShell.Run "taskkill /f /im PrintCtrl.exe", , True oShell.Run "taskkill /f /im PrintDisp.exe", , True
Autoit fileCode: Select all
Const strComputer = "." Set WshShell = CreateObject("WScript.Shell") Dim objWMIService, colProcessList Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2") Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'PrintCtrl.exe'") For Each objProcess in colProcessList WshShell.Exec "taskkill /F /IM " & objProcess.ProcessId Next Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'PrintDisp.exe'") For Each objProcess in colProcessList WshShell.Exec "taskkill /F /IM " & objProcess.ProcessId Next
Code: Select all
ProcessClose("PrintCtrl.exe") ProcessClose("PrintDisp.exe")
I'm speechless.
I don't know why KillProcess fails.
I'm sorry.
Just one more shot: Would there be any invisible trailing space(s)?
Try:
Code: Select all
VBStart
Sub Kill(Process)
Dim oShell : Set oShell = CreateObject("WScript.Shell")
oShell.Run "taskkill /f /im " & Process, , True
End Sub
VBEND
VBRun>Kill,"PrintCtrl.exe"
VBRun>Kill,"PrintDisp.exe"
I think you misunderstood my problem/question, I wanted MS killfunction to work as it should on those 2 process, not integrate vbscript and taskkill into ms.
Reason, simple, I intend to write a macro process killer app to be deploy on computers that have windows xp onwards to 7 or even 8, including
windows xp home which dont have taskkill or wmic features.
If MS native killfunction work properly on my 2 test subject, that means I can begin writing my macro process killer app, but if it isnt, that means I have to put the project on hold.
If you ask me, why not use autoit, reason simple, the autoit app can be decode using decompiler or decompile by autoit experts.
But not MS, from what I read in the forum, the ms compiled exe can only be decompile by Marcus under request, and Marcus already stated in some post(from what I read), unless the request is made by the compiled exe owner him/herself, and also the owner have to had some prove that compiled exe is his/her, then only will Marcus decompile the compiled exe.
Please correct me if the information I read from previous posts are wrong or anything.
Thank you.
Reason, simple, I intend to write a macro process killer app to be deploy on computers that have windows xp onwards to 7 or even 8, including
windows xp home which dont have taskkill or wmic features.
If MS native killfunction work properly on my 2 test subject, that means I can begin writing my macro process killer app, but if it isnt, that means I have to put the project on hold.
If you ask me, why not use autoit, reason simple, the autoit app can be decode using decompiler or decompile by autoit experts.
But not MS, from what I read in the forum, the ms compiled exe can only be decompile by Marcus under request, and Marcus already stated in some post(from what I read), unless the request is made by the compiled exe owner him/herself, and also the owner have to had some prove that compiled exe is his/her, then only will Marcus decompile the compiled exe.
Please correct me if the information I read from previous posts are wrong or anything.
Thank you.
Thanks for now revealing your security concern.newuser wrote:I think you misunderstood my problem/question, I wanted MS killfunction to work as it should on those 2 process, not integrate vbscript and taskkill into ms.
I have never come across the KillProcess failure.
I'm sorry I run out of all ideas.
I'm sorry I don't know the answer.
- Marcus Tettmar
- Site Admin
- Posts: 7391
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Macro Scheduler's KillProcess command simply calls the Microsoft TerminateProcess function:
http://msdn.microsoft.com/en-us/library ... s.85).aspx
If it can't be terminated then maybe you (i.e. an ordinary user / the user level that Macro Scheduler is running at) do not have PROCESS_TERMINATE access rights.
That's why I asked if it made any difference launching Macro Scheduler as admin.
I DO NOT mean setting RP_ADMIN=1 - that won't make any difference whatsoever - that is for subsequent Run commands.
What I mean is to start *Macro Scheduler* (or your .exe) as admin.
Try exiting Macro Scheduler. Then right click on Macro Scheduler and select Run as Admin. Then run your script. Does the process now terminate correctly?
It is normal to require admin rights to kill a process.
http://msdn.microsoft.com/en-us/library ... s.85).aspx
If it can't be terminated then maybe you (i.e. an ordinary user / the user level that Macro Scheduler is running at) do not have PROCESS_TERMINATE access rights.
That's why I asked if it made any difference launching Macro Scheduler as admin.
I DO NOT mean setting RP_ADMIN=1 - that won't make any difference whatsoever - that is for subsequent Run commands.
What I mean is to start *Macro Scheduler* (or your .exe) as admin.
Try exiting Macro Scheduler. Then right click on Macro Scheduler and select Run as Admin. Then run your script. Does the process now terminate correctly?
It is normal to require admin rights to kill a process.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Marcus,
Newuser did afore-mention the overarching OS platforms support:
Newuser did afore-mention the overarching OS platforms support:
Does Admin privilege setting also apply to XP?newuser wrote:Reason, simple, I intend to write a macro process killer app to be deploy on computers that have windows xp onwards to 7 or even 8, including windows xp home which dont have taskkill or wmic features.