I am trying to kill instance of Osk.exe programmatically.
I have a dialogue that allow user to start osk with a button, and if they do not close it themself I close it via the code in closing form.
My code look like this for creation and closing.
Public Sub ClavierCommandExecute()
Dim path64 = "C:\Windows\winsxs\amd64_microsoft-windows-osk_31bf3856ad364e35_10.0.19041.1_none_60ade0eff94c37fc\osk.exe"
Dim path32 = "C:\windows\system32\osk.exe"
Dim Path = If(Environment.Is64BitOperatingSystem, path64, path32)
Me.ProcessusClavier = Process.Start(Path)
End Sub
Public Sub FermerCommandExecute()
Dim processOSK = Process.GetProcessesByName("osk")
For Each proc In processOSK
proc.Kill()
Next
Me.Close()
End Sub
The thing is, if I do this that way, the osk process continue running background. I can tell it because when i lock my laptop, it open back the osk. If it can help i am still on windows 10 64-bit.
But if I close it manually with the close button or even through the task manager, everything work fine.
It would not be a problem normaly, but i feel it created a memory leak by not being killed properly.