I've searched far and wide for this through several similar questions, but none of them have worked so far.
Here is my problem: I have two computers, A running Windows 10 and B running Linux. I have notepad running on Windows. If I go to cmd and type "taskkill /im "notepad.exe"", everything works perfectly, even if I haven't opened cmd as Administrator. However, if I ssh from Linux to windows, and perform the same command, I get the error:
ERROR: The process "notepad.exe" with PID 18756 could not be terminated.
Reason: This process can only be terminated forcefully (with /F option).
Note that I'm ssh'ing into the only user the machine has.
For some reasons, I need to be able to terminate a certain app gracefully, as that way it automatically saves any changes I've already made. If I forcefully terminate via "taskkill /f /im "notepad.exe"", I lose whatever progress I may have forgotten to save.
I've went to Computer Management on Windows and tried adding the "sshd" user as a member of Administrator, but that didn't work (I don't even know why it would work, since I'm sshing into my own user).
I've tried opening an Admin session of cmd through ssh, but no luck as well. It seems the problem is not about privilege. I've also tried "wmic process where name="processname.exe" call terminate", but that also closes everything way too forcefully. It seems that it needs to be "taskkill /im"
Does any one have any idea how i can do this.
Update: Desperate and disregarding any common sense about securities, I coded myself a simple console application which would use keyboard hooks to send a "CTRL + S" keyboard message to the application I often need to save and/or close. Low and behold, Windows is safer than I had given it credit. I can run the console app from my local pc just fine, but attempting to run via ssh fails, as the app cannot find the window using FindWindow(), surely as a security measure. To be quite honest, I am just feeling a little bit silly now. Still no positive updates.
Update 2: Another peculiarity: opening GUI software through ssh does not open them in the machine. It shows on the task manager, but it doesn't really open. Additionally, even if opened through ssh, it stil can not be gracefully terminated via ssh with "taskkill /im ". As Eduardo Bissi had commented, this is most likely due to windows managing different sessions for different users, in specific, the SSH user and the local user. I found a few threads: 1, 2, and it seems the solution is to either call Shellexecute on every received UDP package, which sounds insanely unsafe, or to use a different third party SSH server. I've half given up on this.
Update 3: I've created a Flask server that runs on my machine, and when someone sends a GET request to mymachine:5000/Save, it automatically runs the console application I made earlier, which uses a keyboard hook to send a a "Ctrl + S" keyboard message to the application, managing to save all my progress. Then I can force quit without worries. Since the server was started by the local user, and not via SSH, it has no problem running it. This is the dumbest thing ever.