{"id":6532,"date":"2021-11-19T10:51:14","date_gmt":"2021-11-19T10:51:14","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=6532"},"modified":"2021-11-19T10:51:24","modified_gmt":"2021-11-19T10:51:24","slug":"network-scanner-with-status-indicator","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/show\/batch-network-scanner-with-status-indicator\/873.html","title":{"rendered":"Network Scanner with Status Indicator"},"content":{"rendered":"<p>I created this batch file because I needed a quick way to see what ip addresses were available on my home network in order to assign static ip addresses. I think this could be very useful to others! Let me know what you think or if I can improve it in any way!!<\/p>\n<p>START OF CODE:<\/p>\n<p><i>@echo off<\/i><\/p>\n<p>:Intro<br \/>\necho.<br \/>\necho Network Scanner<br \/>\necho &#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\necho.<br \/>\necho This batch file scans the IP address range with a timeout of 160ms<br \/>\necho.<br \/>\necho.<br \/>\necho Please enter the first three sets of the ip address in this format:<br \/>\nset \/p ipbegin=Example: &#8220;192.168.1&#8221; :<\/p>\n<p>if exist errorchk.bat del errorchk.bat<br \/>\nif exist &#8220;%userprofile%\\desktop\\IP Scan.txt&#8221; del &#8220;%userprofile%\\desktop\\IP Scan.txt&#8221;<br \/>\nif exist &#8220;%userprofile%\\desktop\\Domain Scan.txt&#8221; del &#8220;%userprofile%\\desktop\\Domain Scan.txt&#8221;<\/p>\n<p>::Create errorchk.bat<br \/>\necho @echo off&gt;&gt;errorchk.bat<br \/>\necho echo.&gt;&gt;errorchk.bat<br \/>\necho echo Error level finder&gt;&gt;errorchk.bat<br \/>\necho rem run program&gt;&gt;errorchk.bat<br \/>\necho call %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9&gt;&gt;errorchk.bat<br \/>\necho. &gt;&gt;errorchk.bat<br \/>\necho for \/l %%%%f in (255, -1, 0) do (&gt;&gt;errorchk.bat<br \/>\necho if errorlevel=%%%%f echo Errorlevel=%%%%f&gt;&gt;errorchk.bat<br \/>\necho )&gt;&gt;errorchk.bat<\/p>\n<p>set errorlevel=0<\/p>\n<p>rem Declare variables<br \/>\nset timeout=0<\/p>\n<p>if &#8220;%1&#8243;==&#8221;&#8221; (<br \/>\necho Default timeout used [160 ms]<br \/>\nset timeout=160<br \/>\necho.<br \/>\n)<\/p>\n<p>:settimeout<br \/>\nif %timeout%==0 set timeout=%1<\/p>\n<p>:default<br \/>\nfor \/l %%f in (1, 1, 254) do (<br \/>\nset errorlevel=0<\/p>\n<p>call &#8220;errorchk.bat&#8221; ping -n 1 -w %timeout% %ipbegin%.%%f\u00a0 &gt; nul<\/p>\n<p>rem log entry<br \/>\nif not errorlevel=1 echo %ipbegin%.%%f active&gt;&gt;&#8221;%userprofile%\\desktop\\IP Scan.txt&#8221;<br \/>\nif errorlevel=1 echo %ipbegin%.%%f inactive&gt;&gt;&#8221;%userprofile%\\desktop\\IP Scan.txt&#8221;<\/p>\n<p>if %%f EQU 1 (cls<br \/>\necho.<br \/>\necho [\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ]\u00a0\u00a0\u00a0 0 Percent Complete)<br \/>\nif %%f EQU 25 (cls<br \/>\necho.<br \/>\necho [###\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ]\u00a0\u00a0\u00a0 10 Percent Complete)<br \/>\nif %%f EQU 55 (cls<br \/>\necho.<br \/>\necho [######\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ]\u00a0\u00a0\u00a0 20 Percent Complete)<br \/>\nif %%f EQU 75 (cls<br \/>\necho.<br \/>\necho [#########\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ]\u00a0\u00a0\u00a0 30 Percent Complete)<br \/>\nif %%f EQU 100 (cls<br \/>\necho.<br \/>\necho [############\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ]\u00a0\u00a0\u00a0 40 Percent Complete)<br \/>\nif %%f EQU 125 (cls<br \/>\necho.<br \/>\necho [###############\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ]\u00a0\u00a0\u00a0 50 Percent Complete)<br \/>\nif %%f EQU 150 (cls<br \/>\necho.<br \/>\necho [##################\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ]\u00a0\u00a0\u00a0 60 Percent Complete)<br \/>\nif %%f EQU 175 (cls<br \/>\necho.<br \/>\necho [#####################\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ]\u00a0\u00a0\u00a0 70 Percent Complete)<br \/>\nif %%f EQU 200 (cls<br \/>\necho.<br \/>\necho [########################\u00a0\u00a0\u00a0\u00a0 ]\u00a0\u00a0\u00a0 80 Percent Complete)<br \/>\nif %%f EQU 225 (cls<br \/>\necho.<br \/>\necho [###########################\u00a0 ]\u00a0\u00a0\u00a0 90 Percent Complete)<br \/>\nif %%f EQU 254 (cls<br \/>\necho.<br \/>\necho [#############################]\u00a0\u00a0\u00a0 Network Scan complete)<br \/>\n)<\/p>\n<p>if exist errorchk.bat del errorchk.bat<\/p>\n<p>echo.<br \/>\necho.<br \/>\necho.<br \/>\necho.<br \/>\necho If you would like to get a list of all machines on your<br \/>\necho.<br \/>\necho current domain, please type &#8216;y&#8217; and hit enter.<br \/>\necho.<br \/>\necho.<br \/>\necho Otherwise, press any key to exit&#8230;<br \/>\nset \/p yes= :<br \/>\nif %yes%==y (<br \/>\ngoto domainscan<br \/>\nset errorlevel=0<br \/>\ngoto end<br \/>\n)<\/p>\n<p>:domainscan<br \/>\n:: Scans Network and returns Active Computer Names<br \/>\nnet view \/all &gt;&gt; &#8220;%userprofile%\\desktop\\Domain Scan.txt&#8221;<\/p>\n<p>echo.<br \/>\necho.<br \/>\necho.<br \/>\necho [#############################]\u00a0\u00a0\u00a0 Domain Scan completed<br \/>\necho.<br \/>\necho.<br \/>\necho.<br \/>\necho Please reivew the logs placed on your desktop<br \/>\necho.<br \/>\necho Press any key to exit<br \/>\npause &gt;nul<\/p>\n<p>:end<br \/>\nexit<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":5},"question-category":[55],"question_tags":[],"class_list":["post-6532","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/6532","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=6532"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=6532"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=6532"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=6532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}