Announcement

Collapse
No announcement yet.

Hostname if statements

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hostname if statements

    Hi all,

    I need to make a batch file that is used to shutdown multiple computers on a network. The below was taken from an article on this site and does work, however I am being told that we need to avoid shutting down certain machines. What I was hoping for was the ability to create some sort of IF/ELSE to do this. The commands are...

    Code:
    FOR /L %a in (1,1,254) DO shutdown /s /t 120 /m 10.245.212.%a
    FOR /L %b in (1,1,254) DO shutdown /s /t 120 /m 10.245.213.%b
    FOR /L %c in (1,1,254) DO shutdown /s /t 120 /m 10.245.214.%c
    FOR /L %d in (1,1,254) DO shutdown /s /t 120 /m 10.245.215.%d
    What I guess is needed is something like...

    Code:
    FOR /L %a in (1,1,254) DO nslookup 10.245.212.%a (somehow save the output and save it the address as %host)
    If %host = dt-name-00001 or dt-name-00002 or dt-name-00003
    goto end
    else
    shutdown /s /t 120
    Could someone help me with this?
    Last edited by ]SK[; 22nd June 2011, 12:33.
    Please remember to leave positive reputation points (The Ying Yang Icon) if someone helps you.

  • #2
    Re: Hostname if statements

    not quite the same as what you're trying to do

    but you could create a script that reads from a pre-defined text file.
    then you can just put relevant hostnames in that file, and not put in the ones you don't want shutdown
    Please do show your appreciation to those who assist you by leaving Rep Point https://www.petri.com/forums/core/im.../icon_beer.gif

    Comment


    • #3
      Re: Hostname if statements

      This was considered but sadly the hostnames of the computers changes like the wind on a 1000+ node network.
      Please remember to leave positive reputation points (The Ying Yang Icon) if someone helps you.

      Comment

      Working...
      X