Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Determine if a network computer is online from a batch file

21 Apr 2016   #1
jsquareg

Windows 7 Home Premium (Retail) Full version - With SP1
 
 
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 System SpecsSystem Spec
.
23 Apr 2016   #2
jsquareg

Windows 7 Home Premium (Retail) Full version - With SP1
 
 
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 System SpecsSystem Spec
23 Apr 2016   #3
Alejandro85

Windows 7 Ultimate x64
 
 

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 System SpecsSystem Spec
.

23 Apr 2016   #4
jsquareg

Windows 7 Home Premium (Retail) Full version - With SP1
 
 

Quote   Quote: Originally Posted by Alejandro85 View Post
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 System SpecsSystem Spec
24 Apr 2016   #5
jsquareg

Windows 7 Home Premium (Retail) Full version - With SP1
 
 
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
My System SpecsSystem Spec
25 Apr 2016   #6
jsquareg

Windows 7 Home Premium (Retail) Full version - With SP1
 
 

Quote   Quote: Originally Posted by jsquareg View Post
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.
My System SpecsSystem Spec
25 Apr 2016   #7
Barman58

Windows 10 Pro x64 x2 Windows 10 Enterprise x64, Ubuntu
 
 

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

I've fixed the two posts above
My System SpecsSystem Spec
25 Apr 2016   #8
jsquareg

Windows 7 Home Premium (Retail) Full version - With SP1
 
 

Quote   Quote: Originally Posted by Barman58 View Post
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 System SpecsSystem Spec
25 Apr 2016   #9
Barman58

Windows 10 Pro x64 x2 Windows 10 Enterprise x64, Ubuntu
 
 

No problem, It's easier if you view the Matrix in it's Raw form
My System SpecsSystem Spec
Reply

 Determine if a network computer is online from a batch file




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
How to copy a file from 1 pc to another pc in network using batch file
Help me make a batch file that copies a file from one computer to another computer in a network... PC1 = Source PC2 = Destination I want to copy a file from PC1's Drive E: to PC2's Drive E:
General Discussion
Run Batch File On Remote Computer Without PsExec
Ok imma give a full rundown of the situation. Currently on the network we are on because of the way it is setup wake on lan doesn't work, so SCCM has at best a 70 success rate for patching. So I am currently spending a couple days a week remoting into computers and running a batch file to manually...
Installation & Setup
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
Run batch file when network computer is detected
I'm looking for a way to have a batch file run when a network computer is detected. My laptop is often times inaccessible to my desktop unless I ping it first. So I've created a batch file to ping the laptop but now I need to find a way to have it run when the laptop is detected on my local...
Network & Sharing
Batch file over the network
I am trying to get some inhouse legacy software to work. This is going to be a bit wordy so hold tight. Machine using the software: XP Machine storing the data: Windows 7 Pro The software is homebrewed. The user selects a vessel and needs to program a hardware key. Our program uses a...
Network & Sharing


Our Sites

Site Links

About Us

Find 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 21:23.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App