Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8303995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:41:44+00:00 2026-06-08T17:41:44+00:00

I am trying to write a script where it will prompt you for a

  • 0

I am trying to write a script where it will prompt you for a hostname, say 222012-DC01 from this it will resolve the ip address from dns via ping or nslookup.

It should then modify the ip address to ping the router for that site. If the ip address was 10.123.2.1 it should ping 10.123.1.1 for the router for that site.

The script should give you an output of server offline or router offline.

Work in an enviroment looking after several hundred sites, we take ownership of servers but not network incidents such as a router failure.

Your help is much appreciated…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:41:47+00:00Added an answer on June 8, 2026 at 5:41 pm

    In the future please post what you have got and tried.
    Here is a tested script

    function get_ip(strTarget)
      set objShell = CreateObject("WScript.Shell")
      set objExec = objShell.Exec("ping -n 2 -w 1000 " & strTarget)
      strPingResults = LCase(objExec.StdOut.ReadAll)
      get_ip = ""
      if InStr(strPingResults, "reply from") then
        wscript.echo VbCrLf & strTarget & " responded to ping."
        set regEx = New RegExp
        regEx.Pattern = "\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"
        set matches = regEx.Execute(strPingResults)
        if matches.count > 0 then
          get_ip = matches(0)
        end if
      else
        wscript.echo vbCrLf & strTarget & " did not respond to ping."
        wscript.quit 1
      end If
    end function
    
    function is_online(strTarget)
      set objShell = CreateObject("WScript.Shell")
      set objExec = objShell.Exec("ping -n 2 -w 1000 " & strTarget)
      strPingResults = LCase(objExec.StdOut.ReadAll)
      if inStr(strPingResults, "reply from") then
        is_online = true
      else
        is_online = false
      end If
    end function
    
    pcname = inputbox( "Give the pc-name to ping:")
    ip = get_ip(pcname)
    wscript.echo "ip of pc " & pcname & " is " & ip
    aIp = split(ip, ".")
    aIp(2) = 1
    router = join(aIp, ".")
    wscript.echo "pinging " & router
    if is_online(strTarget) then
      wscript.echo "router is online"
    else
      wscript.echo "router is offline"
    end if
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a script that will download files from an FTP server.
Has anyone noticed this behavior? I'm trying to write a script that will trigger
I'm trying to write a script that will prompt a user for an answer
I'm trying to write a script that will download all the source material from
I'm trying to write a script that will create a user in MediaWiki, so
I'm currently trying to write a script that will connect to a site using
THANKS FOR HELPING!!! Ok... So I am trying to write a script that will
I'm trying to write a Photoshop script that will show all layers of a
I'm trying to write an R script that will go through a dataframe that
I'm trying to write a bash script that will process a list of files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.