Determine if a network computer is online from a batch file


  1. Posts : 400
    Windows 7 Home Premium (Retail) Full version - With SP1
       #1

    Determine if a network computer is online from a batch file


    Under Win 7 I have a batch file in which I want to include an If Exist statement to determine if a specific Network computer is on the network. I thought something like this would work but I keep getting an invalid path error.

    If exist \\HP-Laptop\\ 'do a little something'

    Will some please help me out?

    Thank you.
      My Computer


  2. Posts : 400
    Windows 7 Home Premium (Retail) Full version - With SP1
    Thread Starter
       #2

    Determine if a network computer is online from a batch file


    Under Windows 7, is it possible to determine if a specific computer is logged in to a network? If so, how?

    Thank you.
      My Computer


  3. Posts : 2,465
    Windows 7 Ultimate x64
       #3

    You mean if some other computer is connected and turned on?

    If so, the easiest way is to simply ping it, if it replies it's online. If it fails, it's either powered off, or firewalled (by default Windows allows pings from anyone).
    You can also use that in bat files, and use the returned errorlevel value for further actions.
      My Computer


  4. Posts : 400
    Windows 7 Home Premium (Retail) Full version - With SP1
    Thread Starter
       #4

    Alejandro85 said:
    You mean if some other computer is connected and turned on?

    If so, the easiest way is to simply ping it, if it replies it's online. If it fails, it's either powered off, or firewalled (by default Windows allows pings from anyone).
    You can also use that in bat files, and use the returned errorlevel value for further actions.
    Yes, That is exactly what I should have said. It has been ages since I have pinged something so I will have to dust off my memory bank.

    Thanks so much.
      My Computer


  5. Posts : 400
    Windows 7 Home Premium (Retail) Full version - With SP1
    Thread Starter
       #5

    Determine if a network computer is online from a batch file REVISITED


    I found this snippet of code while searching for things to help me solve the initial problem. It works like I thought it would but I don't understand what the || in the middle of the ping statement does.

    Will someone give me a boost here?

    Thank you.


    ping racer -n 1 -w 100>nul || goto :pingerror


    :pingerror
    echo Host down
    goto eof
    :eof exit /b
    Last edited by Barman58; 25 Apr 2016 at 07:05. Reason: Corrected by Jsquareg
      My Computer


  6. Posts : 400
    Windows 7 Home Premium (Retail) Full version - With SP1
    Thread Starter
       #6

    jsquareg said:
    I found this snippet of code while searching for things to help me solve the initial problem. It works like I thought it would but I don't understand what the || in the middle of the ping statement does.

    Will someone give me a boost here?

    Thank you.


    ping racer -n 1 -w 100>nul || goto :pingerror


    :pingerror
    echo Host down
    goto eof
    :eof exit /b
    I guess when I posted this the double vertical marks were interpreted as a smiley.

    Anyway, never mind. I finally realized the double vertical marks were used to pipe the output of the ping. Like I said it has been a long time since I fooled around in this area.

    Thanks again.
    Last edited by Barman58; 25 Apr 2016 at 07:07.
      My Computer


  7. Posts : 31,242
    Windows 11 Pro x64 [Latest Release and Release Preview]
       #7

    If you ever get this issue you can switch off smiley recognition in the advanced editor

    I've fixed the two posts above :)
      My Computers


  8. Posts : 400
    Windows 7 Home Premium (Retail) Full version - With SP1
    Thread Starter
       #8

    Barman58 said:
    If you ever get this issue you can switch off smiley recognition in the advanced editor

    I've fixed the two posts above :)
    Thank you.
      My Computer


  9. Posts : 31,242
    Windows 11 Pro x64 [Latest Release and Release Preview]
       #9

    No problem, It's easier if you view the Matrix in it's Raw form
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 10:05.
Find Us