Results 1 to 2 of 2

Thread: Simple script required

  1. #1
    Taz
    Taz is offline
    Senior Member Taz's Avatar
    Join Date
    Jan 2005
    Location
    London
    Posts
    2,117
    Thanks
    55
    Thanked
    26 times in 25 posts
    • Taz's system
      • Motherboard:
      • Gigabyte Z270 HD3P
      • CPU:
      • Intel Core i5 7600K
      • Memory:
      • Corsair CMK16GX4M2B3200C16R Vengeance LPX 16 GB
      • Storage:
      • Samsung 960 EVO M.2-2280 500GB (PCIe) + 1TB Sandisk Ultra II SSD (SATA)
      • Graphics card(s):
      • Asus NVIDIA GeForce GTX 1070 OC
      • PSU:
      • Corsair CS550M 550W Hybrid
      • Case:
      • NZXT Source 340
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • 34" Asus Designo Curve MX34VQ UWQHD Monitor
      • Internet:
      • Virgin Media Vivid 200

    Simple script required

    I need help with a script to do the following:

    1. Read a text file that contains IP addresses (one IP address per line)
    2. Read each line of the text file and then call an Operating System command and pass the IP address to the command
    3. Check the return code and log the IP address passed if the command failed by appending it into a failed.txt file

    The script needs to be DOS batch file format or VBscript and run natively on a Windows 2003/XP server using a Command Prompt. Any pointers or the shell of such a script would be appreciated.

  2. #2
    Pedandic mo-fo IAmATeaf's Avatar
    Join Date
    Jul 2006
    Location
    South of the Watford Gap!
    Posts
    962
    Thanks
    2
    Thanked
    21 times in 21 posts
    • IAmATeaf's system
      • Motherboard:
      • Asus P5Q Deluxe
      • CPU:
      • Q6600@3.25
      • Memory:
      • 4 x 2GB Corsair 6400C5DHX XMS2
      • Storage:
      • 2 x 0.5TB 7200.12, 2 x 1.5TB 7200.11
      • Graphics card(s):
      • Gigabyte GTX460 OC
      • PSU:
      • Corsair HX520
      • Case:
      • Lian Li PC6089B
      • Operating System:
      • Windows 7 Pro x64
      • Monitor(s):
      • Samsung T240 24"
      • Internet:
      • 6Mb ADSL Max
    Try this for starters:

    Dim oShell, oFileSys
    Dim sIPAdd, sCommand
    Dim IStream, OStream
    Dim iRet
    Dim bDebug

    Set oShell = WScript.CreateObject("WScript.Shell")
    Set oFileSys = CreateObject("Scripting.FileSystemObject")

    bDebug = True
    sCommand = "Ping.exe "

    Set IStream = oFileSys.OpenTextFile("D:\Deleted\Input.txt", 1, False, False)
    Set OStream = oFileSys.OpenTextFile("D:\Deleted\Failed.txt", 8, True, False)

    Do While IStream.AtEndOfStream = False
    sIPAdd = LCase(IStream.ReadLine)
    If (sIPAdd <> "") Then
    If (bDebug) Then WScript.echo "IPAddress:" & sIPAdd & ":"
    iRet = oShell.run(sCommand & sIPAdd, 1, True)
    If (iRet <> 0) Then
    If (bDebug) Then WScript.echo "Failed: " & sIPAdd
    OStream.WriteLine "Failed: " & sIPAdd
    End If
    End If
    Loop

    IStream.Close
    OStream.Close

    Set oShell = Nothing
    Set oFileSys = Nothing

    File names and locations are hard coded in as is the command but it should be a good starting point. Change bDebug to False to get rid of the debug messages.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Run script on USB Mount
    By Raz316 in forum Software
    Replies: 3
    Last Post: 04-05-2007, 07:57 PM
  2. Replies: 2
    Last Post: 02-03-2006, 03:11 PM
  3. Replies: 0
    Last Post: 10-02-2006, 11:28 PM
  4. Simple Banner Script Javascript or PHP Advice
    By ikonia in forum Software
    Replies: 2
    Last Post: 12-07-2005, 08:29 PM
  5. Simple Backup software required
    By pickers in forum Software
    Replies: 4
    Last Post: 14-03-2005, 08:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •