quarta-feira, 8 de maio de 2019

Habilitar desligamento automatico

Shutdown Windows 10 remotely

In order to enable Alexa to be able to shutdown window PC in our home using voice commands I needed to start by being able to perform the task from my Linux machine using a shell script.
There are a few hurdles I cam across when I was working through setting this up on my windows 10 Pro Desktop.

1. Firewall

If your Linux PC is on the same LAN and in the same IP subnet but is unable to connect to your windows desktop which is evident with returned errors talking of TIMEOUT then try disabling your firewall temporarily for troubleshooting. 
  1. Step 1: Open the Control Panel. Hold down the Windows key ( ) and press “X”. Select “Control Panel” in the menu.
  2. Step 2: Open Windows Firewall Settings. In the Control Panel select “System and Security” …
  3. Step 3: Disable the Firewall. Ensure that both the private and public network firewalls are turned off.
It is recommended that you turn on the firewall after trouble shooting and add an exception for RPC instead, OR if you network type is set to Public and is better suited to be classified as Private then simply change the network type as shown below.
Change Network Category
Open PowerShell with administrative privileges
Run the following command:
Get-NetConnectionProfile
See the network name you want to change its type and run the following command:
Set-NetConnectionProfile -Name “NETWORKNAME” -NetworkCategory Private
Where NETWORKNAME is the name of your network and you can change the -NetworkCategory switch value to Public or Private.

TESTING
From your Linux PC try:
telnet <desktop.IP.Address> 445
If this connects then the firewall is either disabled or configured to pass the RPC traffic through to your desktop.
Example of a successful connection
root@linux:~# telnet 192.168.0.65 445                 
Trying 192.168.0.65…
Connected to 192.168.0.65.
Escape character is ’^]’.


2. UAC (User Account Control)

If you run the ‘net rpc shutdown’ command and see a response similaar to this:
Shutdown of remote machine failed
result was: WERR_CALL_NOT_IMPLEMENTED
To solve this temporarily you could simply disable the UAC but this is certainly not a great position to leave your desktop. I am satisfied with the workaround provided below but you may think differently.
The credit for the UAC workaround goes to  Lowell Heddings, better known online as the How-To Geek.
By default your desktop doesn’t allow UAC elevation over the network with a local user account.
There’s a registry key that we can use to change this behavior to work the same as Windows XP. This will make your computer less secure, and I can’t recommend that you do this… but it’s also good to understand how Windows works.
Manual Registry Hack
Open regedit.exe through the start menu search or run box, and then navigate down to the following key, creating a new key if it doesn’t exist.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
image
On the right-hand side, add a new 32-bit DWORD value named LocalAccountTokenFilterPolicy and set the value to 1.
To remove this tweak you can set the value to 0 or just delete the key.

3. Remote Registry Service

Another error that you may come across when running the ‘net rpc shutdown’ command is this:
could not initialise pipe \winreg. Error was NT_STATUS_OBJECT_NAME_NOT_FOUND
Try running services.msc, scroll down to ‘Remote Registry and make sure it is set to automatic and started (running) then try again.

Linux PC

On your Linux PC use the following command (try apt-get install samba-common if its not already available).
net rpc shutdown -I WIN.IP.ADDR -U USER%PASSWORD
All going well the Windows PC should advise the user they are being signed out and then shutdown.
In a future Post I will look at extending this to explain how to make Alexa shutdown the PC upon request using a script.

Nenhum comentário:

Postar um comentário

RECOVER SENHA UBUNTU