25

I am trying to force a remote shutdown from my laptop to my PC:

machine> shutdown -m \\192.168.2.10 -s -f -t 0
192.168.2.10: Access denied(5)

I am in a WLAN/LAN environment:

  • Laptop is in WLAN with IP 192.168.2.100 (DHCP), Win 7 (64 bit)
  • PC is connected via LAN 192.168.8.10 (static), Win 7 (32 bit)
  • Router IP 192.168.2.1/Subnetmask 255.255.255.0

Access to PC is restricted by username and password.

What do I have to change about the command or about the systems configurations - whilst access restrictions have to remain as is?

Gottlieb Notschnabel
  • 9,408
  • 18
  • 74
  • 116

1 Answers1

40

You can use the NET USE command to authenticate on the remote server and then use shutdown.exe

NET USE \\MyServer\IPC$ mypassword /USER:myuser

http://www.squidworks.net/2011/07/how-to-pass-a-username-and-password-to-windows-shutdown-exe-command/

This does not work with UAC enabled, unless the policy LocalAccountTokenFilterPolicy is enabled on the remote server.

When a user who is a member of the local administrators group on the target remote computer establishes a remote administrative connection by using the net use * \remotecomputer\Share$ command, for example, they will not connect as a full administrator. The user has no elevation potential on the remote computer, and the user cannot perform administrative tasks.

jveazey
  • 5,398
  • 1
  • 29
  • 44
  • 2
    It's basically the server port for the SMB protocol in Windows (http://en.wikipedia.org/wiki/Server_Message_Block#Client-server_approach), which let's you talk to the Windows OS from a different machine. – jveazey Nov 30 '13 at 08:45
  • It doesn't work... I get "The command completed successfully" from NET USE, the I still get "Access is denied.(5)" from shutdown... – lornova Sep 06 '15 at 14:52
  • 1
    I found the cause, it's UAC. I had to enable the policy LocalAccountTokenFilterPolicy – lornova Sep 06 '15 at 15:19
  • Does one have to enable LocalAccountTokenFilterPolicy on the local or the remote machine? – wensveen Apr 13 '16 at 12:07
  • @wensveen It's on the remote server. I've added clarification about LocalAccountTokenFilterPolicy, as well as, a quote from MSDN. – jveazey Apr 13 '16 at 16:57
  • 1
    I was using two windows 10 computers. I still couldn't shut down the other one, until I found this: https://social.technet.microsoft.com/Forums/windows/en-US/4cd01733-0f21-4078-979d-5080bc0c98fb/remote-shutdown-access-denied-5?forum=w7itprogeneral I adapted it for Windows 10. First `RUN secpol.msc`. Then go to: `Local Policies->User Rights Assignment` then `Force Shutdown from a remote system`. Type "Everyone" instead of Administrators, and save. After doing this I no longer even needed to use login credentials in NET USE. I can simply call shutdown. – Joe Oct 19 '16 at 20:05
  • Note: the above advice was to be done on the remote computer. – Joe Oct 19 '16 at 20:15
  • tuning `LocalAccountTokenFilterPolicy` and using `PsShutdown` works fine for Windows 10 allowing it to be remotely shut down from Windows 7 (using administator account) – AntonK Feb 03 '20 at 22:23