Jump to content

Fail to kill DKService.exe process using ProcessClose()


Recommended Posts

I installed diskeeper lite, which is a freeware to defragment drives. It can be downloaded here

To launch diskeeper lite, I run DkLite.msc. This launches a graphic interface for the user to chose which drive he wants to defragment. The associated process is mmc.exe. This is a usual process, can be closed by an AutoIT script via this code:

$PID = ProcessExists("mmc.exe"); Will return the PID or 0 if the process isn't found.
    If $PID Then ProcessClose($PID)

However, it also launches a second process called "DKService.exe", which sounds like a service to me. Anyway, when I manually close this process from the task manager, it works, however, from AutoIT with this code, it fails, the process lives on:

$PID = ProcessExists("DKService.exe"); Will return the PID or 0 if the process isn't found.
    If $PID Then ProcessClose($PID)

In this code, the process is found, but ProcessClose($PID) does *not* kill DKService.exe.

Could some one tell me how I can get rid of the process called "DKService.exe" from AutoIT?

I have to do this, because I run diskeeper from a USB drive, and I need to kill all processes launched from the USB drive before dismounting the drive.

Link to comment
Share on other sites

try this

$Process = \"DKService.exe\"
If ProcessExists($Process) Then RunWait(\"taskkill /F /IM \" & $Process, \"\", @SW_HIDE)

if worked then tell me...

Edited by Jos07

Always Keep Your Sig Small... Like me :D

Link to comment
Share on other sites

I tried this code

$Process = "DKService.exe"
If ProcessExists($Process) Then RunWait("taskkill /F /IM " & $Process, "", @SW_HIDE)

But get Error on 2nd line "Unable to execute the external program". ANy further help?

Link to comment
Share on other sites

  • Developers

Have you tried stopping the started service?

Something like:

RunWait(@comspec & " /c Net stop diskeeper","",@SW_HIDE)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...