- To avoid errors, you can go checking if the station is UP (suggestion from @Oldschool), this before sending the command to turn off, another important thing, would be to send some warning to the user to prevent job loss.
@echo off && setlocal enabledelayedexpansion
color 0A && title ..\%~dpnx0 && mode 100,10 && chcp 1252 >nul
for /f %%i IN (C:\estacoes.txt)do "%__APPDIR__%ping.exe" %%~i -n 2 -4 >nul && (
"%__APPDIR__%ShutDown.exe" /m \\%%~i /s /f /d p:1:2 /c "Salve seus trabalhos, Estação será desligada em 300 segundos!!" /t 300 2>nul
) || ( Echo/ & echo/ Estação %%~i nao responde Pings ou o Agendamento de Desligamento jah esta em curso)
endlocal && goto :EOF
- Also quoted in that reply Q426377 - Pretty much the same theme/response
Remote access has to be enabled on the station by a configuration that is done locally, not just send an access request and/or a command, the other stations where (in another domain or not) your command has worked, is the result of a configuration applied when previously required.
This restriction came by default from Windows Vista, allowing remote (filtered) access to only admin group members local.
Via prompt perform a reg query
in the key below and check if it returns to you:
EnableLUA REG_DWORD 0x1
or EnableLUA REG_DWORD 0x0
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" | findstr "EnableLUA"
Rem :: EnableLUA REG_DWORD 0x1
rem :: Então adicione a entrada/valor 0
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableLUA /t REG_DWORD /d 0 /f
In short:
Check in the destination station, if this key exists and if it is enabled(0x1):
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system" | find "LocalAccountTokenFilterPolicy" | find "0x1"
If it exists and is enabled, the command returns to you:
LocalAccountTokenFilterPolicy REG_DWORD 0x1
In case it does not exist or the value differs from 0x1, use this command to add/enable:
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system" /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f
Puts a
PAUSE
at the end of the document and then you can look at the errors that occur.– Guilherme Nascimento