❔ ✅ Help getting remote launch to perform task (display off)
I've got an application that just turns off a monitor, nothing super complicated about it:
The problem is that this application exists on a laptop which is all but dead. The keyboard barely works and if I press too hard the wifi will stop working until restart, the trackpad doesn't work, the usbs don't work, the power button barely works. I can remote into the system using SSH, but when I run the application using either start process.exe, psexec -i -d -u user -p "pass" "process.exe", or runas /user:user process.exe, it simply doesn't work. It'll tell me things like that the process has been created, but it won't turn the monitor off as it's supposed to. If I slam on the keyboard enough to run the app manually, it'll turn off the display, but that causes the wifi to stop working, so I'd really like to know how I can make the application run even when remotely executed using SSH.
11 Replies
Did you check return codes/global error codes set by WinAPI?
I didn't.
Let that be the first thing you do.
SendMessage
returns LRESULT
, you have GetLastError
Okay, I'll have to save LRESULT to a txt file or something, then read it.
I'd also read this carefully: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendmessage#remarks
Especially
When a message is blocked by UIPI the last error, retrieved with GetLastError, is set to 5 (access denied).
Alright, I've modified the code. I'll have to scp it onto the remote system, then try the 3 different run methods. After that, I'll update you with the error codes.
Under all run conditions, the errorcode returned is 0.
Seems like it's running as expected. I have a feeling the issue is with the "GetConsoleWindow()".
I'm thinking ssh is not allowing it to get the console window's handle, so I'm going to try a different approach.
Well, check the error code for that
I kind of cheated. I wrote a powershell script to create a scheduled task which starts the C# app, then I just ran the scheduled task from ssh. It works.
I guess it doesn't really matter how I get to point B, as long as I get there.
I'm not a huge fan of requiring my apps to be run from task scheduler any time I need to run something using ssh, so I figure I'll probably create a C# application which can run any other application, and then put that in the taskscheduler, then I'll create another C# application that can run that task with the parameters for easier execution. It's a bit complicated, but I think that's going to be the best way to go about things.
Thank you by the way, for attempting to help diagnose the issue.
Am I supposed to close this channel or something?
That is a very good question! Maybe try
!close
!close
Closed!
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.