Astrologic
Astrologic
CC#
Created by Astrologic on 2/17/2023 in #help
❔ ✅ 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:
internal class Program
{
[DllImport("kernel32.dll")]
static extern IntPtr GetConsoleWindow();

[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);



private static int WM_SYSCOMMAND = 0x0112;
private static uint SC_MONITORPOWER = 0xF170;

public static void Main(string[] args)
{
SendMessage(GetConsoleWindow(), WM_SYSCOMMAND, (IntPtr)SC_MONITORPOWER, (IntPtr)(2));
}
}
internal class Program
{
[DllImport("kernel32.dll")]
static extern IntPtr GetConsoleWindow();

[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);



private static int WM_SYSCOMMAND = 0x0112;
private static uint SC_MONITORPOWER = 0xF170;

public static void Main(string[] args)
{
SendMessage(GetConsoleWindow(), WM_SYSCOMMAND, (IntPtr)SC_MONITORPOWER, (IntPtr)(2));
}
}
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.
21 replies