ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Solved Script Assistance requested

    IT Discussion
    batch script scripting windows 8.1 windows 8 windows 10 drive mapping vpn
    2
    3
    1.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      gjacobse
      last edited by gjacobse

      Looking to update and expand the function of a drive mapping script I have for a client with remote users. They connect via a VPN, and many times we find that we much re-run the map-drives batch to reconnect them to their share drives.

      I would like to add to that script by a 'go / no-go' process - basically is the computer connected via the VPN.

      I found this script, which works decently enough when testing it. However, it requires another file to be added which would have just an IP address in it. I would like to remove that (the in (pcs.txt) part and replace with with the IP address I want to check.

      I do see that they use %1 in the HOSTUP and HOSTDOWN

      @echo off
      @echo off http://stackoverflow.com/questions/9329749/batch-errorlevel-ping-response
      
      setlocal enableextensions enabledelayedexpansion
      
      for /f %%i in (PCS.TXT) do (
         SET bHOSTUP=0
         ping -n 2 %%i |find "TTL=" > NUL && SET bHOSTUP=1
         IF !bHOSTUP! equ 1 (
            CALL :HOSTUP %%i
         ) else (
            CALL :HOSTDOWN %%i 
         )
      )
      GOTO EOF
      
      :HOSTUP
      echo Host UP %1
      GOTO EOF
      
      :HOSTDOWN
      echo Host DOWN %1
      GOTO EOF
      
      :EOF
      exit /B
      
      1 Reply Last reply Reply Quote 0
      • M
        Mike Davis
        last edited by Mike Davis

        Here you go:

        @echo off
        rem tweaked from http://stackoverflow.com/questions/9329749/batch-errorlevel-ping-response
        
        setlocal enableextensions enabledelayedexpansion
        
        
           SET bHOSTUP=0
           ping -n 2 192.168.0.24 |find "TTL=" > NUL && SET bHOSTUP=1
           IF !bHOSTUP! equ 1 (
              CALL :HOSTUP 
           ) else (
              CALL :HOSTDOWN 
           )
        
        GOTO EOF
        
        :HOSTUP
        echo Host UP 
        GOTO EOF
        
        :HOSTDOWN
        echo Host DOWN
        GOTO EOF
        
        :EOF
        exit /B
        
        
        1 Reply Last reply Reply Quote 5
        • G
          gjacobse
          last edited by

          Thanks @Mike-Davis

          That is just want was needed. added it to my other script and works great thus far.

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post