Do you actually NEED an EZ Network Scanner?
Do you actually NEED an EZ Network Scanner?
I made a funny little script to check the connections on your computer network. It shows you the Process ID and which service is using that connection. This thing will change itself every ten seconds so you can see your network working live. To make this work, open Notepad on Windows 10, save it as an .bat file, and put all these words inside:
@Echo off
cd /d C:\Windows\System32
for /f "tokens=5" %%a in ('netstat -ano ^| findstr /i "established" ^| findstr /r /c:"[ ][0-9].[0-9].[0-9].[0-9]:[0-9][ ][0-9][ ]*ESTABLISHED") do @(echo PID: %%a & tasklist /svc /fi "pid eq %%a")
timeout /t 5 /nobreak >nul
goto loop
It doesn't look like this works. There is an invalid argument error. The folder path for c:\Users\REDACTED\Desktop shows 274 test.bat files, which total 274 bytes and have a disk space of 79,053,303,808 bytes free on the drive. Running the command netstat -ano | findstr /i "established" in that folder did not work as expected because it is missing the proper argument for that tool. The correct way to run this tool is with a flag named '/t', but I typed 'test.bat off' instead of that. If you try using just 'netstat -ano', then it works fine and gives useful output. Also, when running scripts in Windows Command Line, please use the REM command to comment your lines so they are ignored by the system. Each line needs an explanation on what it does because very few people will blindly copy and run a script without looking at it first. I ran this test just as a precautionary measure before sending it out for you to check. = = = = @klavs Something seems to be missing from your message.
Your test.bat file only contains variables named a, so it can't see other things like the folder or path you are looking for.
It's because @gmikkonen didn't format his code snippet correctly. I cleaned up and changed it so you can see it better. Here is the text: @echo off @rem cd /d C:\Windows\System32 :loop cls for /f "tokens=5" %%a in ('netstat -ano ^| findstr /r /c:"[0-9]:[0-9].*[0-9]:[0-9].*ESTABLISHED") do @(tasklist /svc /fi "pid eq %%a") ^| findstr /r /c:"[0-9]" timeout /t 5 /nobreak >nul goto loop The OP told you to save the file with a .bat extension or change it to .cmd. It's not a network scanner, it just shows which connections are active right now.
@klavs Thanks a bunch. @MrLitschel - cool thing. Not sure why one of those "%"s is missing on this side. Pasted the whole line over and over again. Everything else after the first % disappears when that error pops up. I'm wondering... Will check it out later. = = = = FYI everyone, Have you tried or used PowerShell before? If not, I'd recommend it, especially if you're into IT stuff.
It won't work like a CMD batch extension because it's not designed for that. When you write @Echo off at the top, the script hides its own commands from showing up on screen, which makes everything look cleaner. The command cd /d C:\Windows\System32 changes where we are working to a folder full of Windows system files. Then the label for.cls tells us to clear the screen first so when we start again it looks fresh. For /f with tokens=5 loops through the netstat output looking specifically for lines like [ ][0-9].[0-9].[0-9].[0-9]:[0-9][ ][0-9][ ]*ESTABLISHED to find established connections. It then uses tasklist /svc and /fi flags to show details about which processes have those active connections. The timeout command waits for five seconds before starting the next check, but /nobreak stops it from stopping if you press a key. This line just jumps back up to the loop label so it keeps going over and over again finding these running processes every single five seconds.
CMD works with BAT, which was common back in DOS when we used 16-bit systems. If you haven't formatted your code properly, it's very hard to read. You should look at your own post and add a comment there instead. I already told you to use the CODE tag so things are clearer. Here is how I did it: https://imgur.com/a/mE7yxMz Check out this image for more details too: https://imgur.com/a/mE7yxMz
Command: @echo off cd C:\Windows\System32 :loop clear screen for each line in ('netstat -ano | findstr "established"') do @(echo PID: number & tasklist service pid equal number) wait 5 seconds then go to next iteration
Nice. Thanks for sending over your script and helping people learn how to write batch scripts. You don't have to change the current working directory to C:\Windows\System32, because that folder is already in the PATH environment variable. There is no need to put a @ symbol before the "tasklist" command, since "echo" has been turned off so it won't print anything else first. To get help with commands, you can write "help <name of command>" or "<name of command> /?". When looking for the word "established", don't ignore capital letters because netstat always shows it in upper case. So, you can remove this statement from your command: Code: ^| findstr /i "established"