Page 1 of 1

Shutdown last running pc on the LAN with Synology Server

Posted: 04 Feb 2015 08:45
by ruelle
I have a LAN with 4 PCs and one Synology server. I wish that every time a computer is turned off, it runs a batch (from windows pc) and see if other PCs are on, - if any is on do nothing, - otherwise runs a command that shuts down the server.
Here is what I have at the moment:

Code: Select all

@echo off 
PING 192.168.1.10
IF %ERRORLEVEL% EQU 1 plink root@192.168.1.10 -pw MYPASSWORD shutdown -s -t 00


But I would like to do something like:
http://i.imgur.com/BLAVCBt.png
Image

Thank You!!

Re: Shutdown last running pc on the LAN with Synology Server

Posted: 04 Feb 2015 10:07
by foxidrive
This is untested and a basic arrangement - but for 4 PC's it'll do:

Code: Select all

@echo off
set "flag="
ping 192.168.1.1 -n 2  |find /i "TTL=" >nul && set flag=1
ping 192.168.1.2 -n 2  |find /i "TTL=" >nul && set flag=1
ping 192.168.1.3 -n 2  |find /i "TTL=" >nul && set flag=1
ping 192.168.1.4 -n 2  |find /i "TTL=" >nul && set flag=1
if not defined flag echo shutdown server


If you provide the IP addresses then some testing that eliminates the current machine can be added.

Re: Shutdown last running pc on the LAN with Synology Server

Posted: 04 Feb 2015 10:19
by foxidrive
The same question has been repeated everywhere: http://ss64.org/viewtopic.php?pid=8186#p8186

Re: Shutdown last running pc on the LAN with Synology Server

Posted: 04 Feb 2015 17:03
by ruelle
Sorry for crossposting :D

ss64*org/viewtopic.php?pid=8188

stackoverflow*com/questions/28304099/batch-script-to-ping-other-pc-in-my-lan-and-shutdown-together-last-online-pc

www*msfn*org/board/topic/173438-shutdown-last-running-pc-on-the-lan-with-server/

forum*synology*com/enu/viewtopic*php?f=145&t=96609&p=364122#p364122

www*dostips*com/forum/viewtopic.php?f=3&t=6245

I think last one will be more easy to use thank you for the answer!

@echo off
set "flag="
ping 192.168.1.1 -n 2 |find /i "TTL=" >nul && set flag=1
ping 192.168.1.2 -n 2 |find /i "TTL=" >nul && set flag=1
ping 192.168.1.3 -n 2 |find /i "TTL=" >nul && set flag=1
ping 192.168.1.4 -n 2 |find /i "TTL=" >nul && set flag=1
if not defined flag echo shutdown server