Shutdown last running pc on the LAN with Synology Server

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ruelle
Posts: 2
Joined: 04 Feb 2015 08:41

Shutdown last running pc on the LAN with Synology Server

#1 Post by ruelle » 04 Feb 2015 08:45

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!!

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

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

#2 Post by foxidrive » 04 Feb 2015 10:07

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.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

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

#3 Post by foxidrive » 04 Feb 2015 10:19

The same question has been repeated everywhere: http://ss64.org/viewtopic.php?pid=8186#p8186

ruelle
Posts: 2
Joined: 04 Feb 2015 08:41

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

#4 Post by ruelle » 04 Feb 2015 17:03

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

Post Reply