Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

SCRIPT THAT PINGS MULTIPLE IP'S AND THEN DOES AN ACTION

- - - - -

  • Please log in to reply
4 replies to this topic

#1
Haris1977

Haris1977
  • Member
  • 2 posts
  • Joined Today, 04:03 AM
  • OS:Windows 7 x86
  • Country: Country Flag

Greetings

 

I am trying to make a batch file (i guess a *.bat would be ok) but i am not a proggramer. What i want to do is a bat file with 4 steps:

 

1) Ping a range of ip's (192.168.1.100 to 192.168.1.115)

2) If the script finds at least ONE active IP from the specific range (e.g 192.168.1.104) it continues to ping the ip's. Thus mean it would loop all ip's all the time

3) If the script doesn't find ANY active ip then make my server pc to sleep (not restart). I think the cmd command is :

rundll32.exe powrprof.dll,SetSuspendState 0,1,0

4) If pc wakes then restart all steps 1-3

 

My server pc is a win7 ultimate X86 laptop

 

Is that possible?

 

Thanks!

 

 

 




How to remove advertisement from MSFN

#2
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,418 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag
Sure it is possible.
Something *like*:
 
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SET BaseRAnge=192.168.1
SET Min=100
SET Max=115
SET Counter=0

FOR /L %%A IN (%Min%,1,%Max%) DO (
ECHO Pinging %BaseRange%.%%A
PING -n 1 %BaseRange%.%%A >nul 2>&1 &&SET /A Counter+=1
)

IF %Counter% GTR 0 (
ECHO Successful ping[s] %Counter%
) ELSE (
ECHO No successful pings
)
should do.
 
jaclaz

Edited by jaclaz, Today, 04:42 AM.


#3
Haris1977

Haris1977
  • Member
  • 2 posts
  • Joined Today, 04:03 AM
  • OS:Windows 7 x86
  • Country: Country Flag

Thanks jaclaz. But when i run it and the line goes to

 

pinging 192.168.1.115

 

the script stops. It doesnt make my pc to sleep.. :(

 

Same thing happens when an ip is active..Smth is missing here..


Edited by Haris1977, Today, 06:11 AM.


#4
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 9,817 posts
  • Joined 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Donator

Use the full post editor to fix your topic title. :thumbdown

 

11. Do not use CAPITALIZATIONS in the topic title or when participating in threads because they will not attract attention - instead it will annoy many of MSFN's members. Using unnecessary font formatting (i.e., bold font, increased font sizes, colored fonts, etc.) on the full body of posts is also discouraged.

 

:hello:


MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
msfn2_zpsc37c7153.jpg

#5
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,418 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

Sure, what I posted is obviously just an example, in order to give you some ideas in order to help you write your own batch.

The two actions executed are just ECHO commands, you should replace them with the action you want to be executed in one case or the other.

 

I read the:

 

I am trying to make a batch file ...

as "I am trying to make a batch file ...." ;) and NOT as "I am wanting someone to write a batch file for me ..." :whistle:



jaclaz






4 user(s) are reading this topic

0 members, 4 guests, 0 anonymous users



How to remove advertisement from MSFN