3

I’m looking to be able to remotely power on my Windows machine and start a program.

I have WoL (Wake on LAN), and a SSH Server configured so I’m able to remotely turn on the machine and remotely access it.

I’d like to be able to next log in a desktop session on that machine (as it will be on the login screen on boot up). Is this possible?

Just to clarify a couple things:

  1. The SSH session I have is authenticated and “logged in” with my user. Im specifically talking about logging in the machine from that session from the perspective of if someone was physically looking at the monitor output.
  2. I don’t want to remove that login screen from boot up, because most of the time I still want the security of having a login process.
  3. I will eventually want to start a gui application in that desktop, so running a process in the ssh session is not what I’m after.
  4. I also do not want to use something that requires human intervention, I.e. using Windows Remote Desktop and having to log in that way.

Edit: Here’s an example. I want a script I want run from a remote machine, which will turn on the computer (WoL current solution), then open a desktop application like the calculator app.

The script itself does not need to interact with that calculator app, but just needs it to be opened for the desktop session of the target windows machine. I.e after the script has run and a user sits down physically at the target windows machine, the calculator app is open on their desktop.

The solution doesn’t need to be ssh, I just assumed an authenticated ssh session would have been part of a solution. But other methods of remote authentication and sending commands are welcome. Though I am looking at running this script from a Linux machine.

Hope that clarifies what I mean by opening a GUI app remotely, and no human intervention.

Final Edit: Check the final reply to the accepted answer for my final solution.

11
  • How do you plan to run Windows applications remotely with only OpenSSH?
    – Ramhound
    Commented May 7, 2023 at 15:35
  • You could look into Chrome Remote Desktop. remotedesktop.google.com That shares the desktop and gives access to the login screen but doesn't require Windows Remote Desktop. Just requires a Google Account and a PIN.
    – TechLoom
    Commented May 7, 2023 at 15:49
  • 1
    Try Radmin Tools. Works great
    – anon
    Commented May 7, 2023 at 15:57
  • Install a VNC server on the computer and set it to run at boot with a static password, so it will be available at all times. I have used TeamViewer like that with good results, but there are others.
    – harrymc
    Commented May 7, 2023 at 16:55
  • @Ramhound I don’t plan to use them over SSH, I only need it to be opened. For the other comments suggesting other remote access tools, thanks but, to clarify point 4, is not that I just don’t want to use Windows Remote Desktop, specially, I don’t want to use any remoting tool that requires a human to interact with. The thing I’m working towards is a fully automated script
    – freebie
    Commented May 8, 2023 at 0:31

2 Answers 2

0
+100

This solution uses ## Part 1 logic which is run once from a session where you will be launching the RDP from to automate the connection part where no human interaction is needed to launch and sign onto the RDP session after this is saved. You will type in the username, password, and machine name on prompt.

The ## Part 2 logic is the only part really used to automate the launching of the RDP session where human interaction is not needed if the machine name connecting to is the same as the one you specified when you part 2 was run. You'll need to execute this as the same user account/security context and from the same machine which you ran part 1 to embed the credential for subsequent RDP connection automation.

This just means, run the part 1 once with human interaction, then setup automation to run part 2 specifying the machine to connect via RDP so it'll connection automatically.

PowerShell

## Part 1
$User = Read-Host "Enter username (e.g. domain\user1)";
$P = Read-Host "Enter password" -AsSecureString;
$psw = New-Object System.Management.Automation.PSCredential -ArgumentList $User,$P;
$Password = [System.Net.NetworkCredential]::new("",$psw.password).Password;
$MachineName = Read-Host "Enter machine name (or IP address)";
cmdkey /add:$MachineName /user:$User /pass:$Password;

## Part 2
mstsc /v:"machine123";

## How to delete saved credential from command
#cmdkey /delete:"machine123" 

The method above is really just the PowerShell equivalent to saving an RDP credential for usage with mstsc per the GUI option from the Windows Security credential pop-up of checking "Remember Me".

When you check Remember Me using the GUI, the next time you go to connect to the same machine via RDP using mstsc, you can press connect and it'll use the saved credential to login.

enter image description here

enter image description here

Lastly, drop a shortcut of the application which you want to run when the RDP session connects in the C:\Users\User1\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup folder. This will execute the shortcut and run the app when that specific user logs in on that machine. You can also do this a couple other ways with Task Scheduler being one of them with delay run options, etc. if needed.

Supporting Resources

6
  • Here you go @freebie, I believe this is what you are looking for as I've used it to help automate RDP connections to tens of machines at once but this is the simplified version of that. If you need more help or guidance with the launching of the task once RDP connects, I'm happy to make adjustments but that's also just a trivial matter. I gave you a simple solution for that in case you were not already aware of also needed some suggestions for that part as well. I look forward to hearing if you were able to use this solution for what you're seeking help with here. Commented May 14, 2023 at 23:08
  • I just saw your edit, WOL is the way to go for waking up a machine though. I have a solution I used but if you are on the same subnet, that should work just fine. If not, you may need iphelper rules in your router configs to allow those broadcast packets of port 7 or 9 across subnets. If you have a machine you can automate an invoke-command and then run some WOL logic from it (across subnets otherwise), it could also WOL of that machine with its MAC address. This is something else I've automated in the past and have a few scripts saved. I wrote answer before your edit, ping me back though. Commented May 14, 2023 at 23:13
  • This looks promising, I’ll have to try it out. I appreciate the detail as well. So there are a few assumptions here that it’s need to see will still work in my situation. Those being this looks like it’sa script ran from another windows machine, though that’s not the case in my set up, it’ll be a Linux machine. Also I don’t want the application to always start when the machine is conventionally booted, only when the script is responsible. Thanks again, will have a play around in the evening
    – freebie
    Commented May 14, 2023 at 23:24
  • Here are a few links for potential automation using Linux RDP tools, same concept those with that as suggested here: superuser.com/questions/628371/…, reddit.com/r/Remmina/comments/bpa7qs/…, stackoverflow.com/questions/9120054/…, and opensource.com/article/18/6/linux-remote-desktop. Adjusting options for automation using such tools is still just a trivial matter, the basis is the same using those tools as answered. Commented May 15, 2023 at 13:31
  • 1
    OK, so I ended up not needing RDP, I just had to solve how to get Windows to open a .exe application via SSH. This turned out to be by having to make a Windows Scheduled Task and manually running it (see: superuser.com/questions/1470433/… and winhelponline.com/blog/…). So the solution is WoL to turn on the machine, then establish a ssh connection with the command C:\Windows\System32\schtasks.exe /RUN /TN "Open My App".
    – freebie
    Commented May 15, 2023 at 18:40
0

What you're looking for is a KVM over IP console. It is an external piece of hardware that allows you to issue commands as if you were physically at the computer and also view the screen. As it is external hardware, it does not require the operating system, so you are able to access OS login screens and even the BIOS itself.

They are highly customizable and if you are comfortable with buying one, I'm sure they'd fit your use case.

Now, this doesn't answer the part about using SSH credentials to log-in, but depending on the model you chose, you could very easily write a simple script to allow you to do that.

1
  • 1
    Thanks for the response, though a KVM I do not believe suits my requirement. Maybe it could but must be a simpler way. In this I would need a KVM with its own command line interface I could send automated commands to. Don’t feel built for what I’m after. A KVM is design for interactive remote access for an active human user.
    – freebie
    Commented May 14, 2023 at 23:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .