Question Remote shutdown PC on same network

Feb 12, 2022
13
1
25
I have a server and laptop both running Windows 10.
I would like to remote shutdown/restart the server using my laptop.

I have tried on the server:
  1. Opening "services.msc" > Remote Registry > Properties
  2. Setting "startup type" to "Automatic"
  3. Then starting the service
  4. Opening windows firewall > Allowed WMI
Then from laptop:
1) Ran this command from powershell: shutdown.exe /m \\[server_static_ip] /r /t 0

I got the error "Access is denied"

I then tried on the server:
  1. Creating a new local administrator account (via Account settings > Family & other users > Add someone else to this PC)
  2. Then opening Remote Registry > Properties > Log on
  3. Selecting "this account" option and browsing for the newly-created user (let's call this user ADMIN2 going forward)
  4. Then setting the password to be the same as ADMIN2's account password and saved
  5. Then I stopped/started the Remote Registry service
Then from laptop:
1) Ran this command from powershell: net use \\[server_static_ip]\IPC$ [new_admin_pwd] /USER:[new_admin_username]

I got an error: "System error 1219 has occurred. Multiple connections to a server or shared resource by the same user..."
So I tried restarting the server and trying again, only to get the same error.

I then tried:
  1. Opening "Remote Registry > Properties > Log on" again
  2. Setting the main admin account as the "log on user" (the one I login directly with) which doesn't have a password*
  3. Setting the password to be the same as the one I used for ADMIN2
  4. Tried restarting the Remote Registry service
Got an error: "Error 1069: The service did not start due to a logon failure"

* the reason I don't have a password on the main account is to allow the server to start up automatically without any interaction from me*
(e.g. in case I'm not home and others want to use it)


I'm a bit lost. Not sure how to set up remote shutdown on my server.
Help would be greatly appreciated!

Note:
  • The shutdown procedure will only be done on the local network
  • The shutdown command will only come from a single laptop (with a static IP too)
  • Preferably I'd like to avoid requiring a username/password to initiate the remote shutdown (instead, if possible, I could restrict the command to only my laptop's IP)
  • I'd like to initiate the shutdown command using the server's IP rather than a ComputerName
I'll eagerly await your replies!
 
Last edited:
Why you need to enable "Remote Registry" in order to remote shutdown?
You can have an account with very simple password for others to use. Make sure this account does not have adminsitrative rights.
If you version of Windows is Pro, you can also RDP into the "server" to shut it down.
 
use this tool:https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/starting-a-remote-exe-session

it comes with the windows debugger tools.
on the server you would run
remote.exe /s "cmd.exe" MyName

then on the laptop you would run
remote.exe /c laptop MyName

(laptop is my servername, sorry, poor choice of names)
you can run remote.exe /? and it will tell you the correct syntax. when you start a server it gives you the command the client will need to connect to the server.

I just set up a server on one cmd window and a client on another cmd windows to confirm it still works.

then you would run your shutdown command to shutdown or reboot the server.
this method uses named pipes and all command would be executed on the server so you do not need to provide the ip address or usernames or passwords.
(context would be of the server cmd.exe window and how ever it was started, I assume you would use a server local account that has rights to reboot/shutdown the machine.


funny: looks like the shutdown command can shutdown remote machines now. (never used it)
https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/shutdown
 
Last edited:
thinking about why you got and access denied error:
you need to make sure there is no connection from the laptop to the server before you attempt to connect to the IPC$ admin share.
if there is already a session then that sessions credentials will conflict with then newly provide credentials.

so you would want to disconnect all connections from the laptop to the server by using something like
net use \\servername * /d
before you use your
net use ipc$ /u:username /p:password
(sorry have not done this in years, will have to try it again.)
 
You an use powershell's invoke-command for this. First, try shutting down the server from inside using a script. You'll need to be running as an user that has administrative rights to shut it down and also "run as batch" to be able to run scripts.

Once that works, make sure you allow remote Powershell using "Enable-PSRemoting" on the server. In the local workstation, make sure the remote server is in your trusted hosts (Set-Item wsman:\localhost\client\trustedhosts 'hostname'). You should check with Get-Item first to see if there are existing values because they would be overridden.

With that done, create your script like:

$credential = get-credential
Invoke-Command -ComputerName 'SERVER' -credential $credential --ScriptBlock {
whatever commands you used locally to shut down the server
}
 

Latest posts