Ad-Hoc Network (Hotspot) Manager Dengan Command Prompt


Lama tak berbagi rasa-rasanya kangen juga, dan kali ini saya ingin berbagi Ad-Hoc Network (Hotspot) Manager dengan Command Prompt atau biasa disebut cmd. Dimana fungsi alat ini adalah untuk memenej Virtual Network pada sistem operasi berbasis Windows, adapun fitur-fitur yang tersedia dari alat ini diantara lainnya adalah membuat virtual network, melihat virtual network, mengedit, dan menghapus virtual network, etc.

Sedikit cerita ya my lord, tadinya alat ini saya buat karena rasa jengkel saya terhadap teman saya dikarenakan terlalu sering ingin mendapatkan koneksi internet dari laptop saya yang sedang terhebubung pada jaringan Wi-Fi, jadinya saya harus membuat virtual network agar bisa sharing internet connection pada teman saya.

Karena teman saya terlalu sering meminta agar jaringan pada laptop saya dibagikan, dimana saya harus menulis secara manual perintah-perintah pada cmd step by step jadinya saya jengkel juga jika harus terus menerus menulis ulang perintah-perintah pada cmdnya, untuk itu saya kepikiran gimana kalo diaplikasikan saja dan dijadikan program sederhana. Hanya untuk kamu dan aku..

Akhirnya saya gugling deh mencari referensi tentang batch script, muter-muter sana-sini, nyeduh kopi buat gadang, kalo soal gadangnya sih bukan buat bikin tool ini, tapi ya emang keseharian suka kadang juga, sembari gadang kadang ngulik-ngulik dikit, mulai bosen, buka sosmed, bosen sosmedan, buka game, bosen ngegame, buka baju, beres buka baju, buka celana, dingin, pake lagi baju sama celana. bete ya bacanya? to the point ajalah.. heuuu

Berikut adalah source codenya, bisa kalian kembangkan lagi, mungkin menjadi program GUI, tapi harus pake batch script GUInya. Mampus..


rem # Ad-Hoc Network Manager © Iqbar Alhakim - 2017
@echo off
title Ad-Hoc Network Manager
color 2

:menu
cls
echo.
echo "[*********************************************************************]"
echo "[  _       _                    _______ _  _           _     _        ]"
echo "[ | |     | |                  (_______) || |         | |   (_)       ]"
echo "[ | | ____| |__  _____  ____    _______| || |__  _____| |  _ _ ____   ]"
echo "[ | |/ _  |  _ \(____ |/ ___)  |  ___  | ||  _ \(____ | |_/ ) |    \  ]"
echo "[ | | |_| | |_) ) ___ | |      | |   | | || | | / ___ |  _ (| | | | | ]"
echo "[ |_|\__  |____/\_____|_|      |_|   |_|\_)_| |_\_____|_| \_)_|_|_|_| ]"
echo "[       |_|                                                           ]"
echo "[                                                                     ]"
echo "[                                                                     ]"
echo "[ Twitter : @iqbaralhakim                                             ]"
echo "[ Site    : http://iqbaralhakim.id                                    ]"
echo "[ Blog    : https://ziixo93.blogspot.com                              ]"
echo "[                                                                     ]"
echo "[                                                                     ]"
echo "[*********************************************************************]"
echo.
echo.
echo ============================================
echo ------------------- Menu -------------------
echo ============================================
echo.
echo - [1]  : Aktifkan Ad-Hoc
echo - [2]  : Nonaktifkan Ad-Hoc
echo - [3]  : Buat Ad-Hoc Network
echo - [4]  : Lihat Status Ad-Hoc
echo - [5]  : Lihat Pengguna Ad-Hoc
echo --------------------------------------------
echo - [6]  : Lihat Kata Sandi
echo - [7]  : Ganti Kata Sandi
echo --------------------------------------------
echo - [8]  : Hapus Ad-Hoc Network
echo - [9]  : Bersihkan Cache DNS
echo - [10] : Reset Winsock Network
echo - [11] : Test Compatibility (Pengguna Baru!)
echo --------------------------------------------
echo - [H] - Bantuan
echo - [X] - Keluar
echo.
echo ============================================
echo.
set choice=
set /p choice=Masukan Pilihan: 
echo.
echo ============================================
echo.
echo Tunggu Sebentar...
echo.
timeout /t 1 >nul
cls
if %choice%==1 goto on
if %choice%==2 goto off
if %choice%==3 goto create
if %choice%==4 goto status
if %choice%==5 goto viewuser
if %choice%==6 goto viewpass
if %choice%==7 goto changepass
if %choice%==8 goto deleteadhoc
if %choice%==9 goto cleardnsnetwork
if %choice%==10 goto resetwinsock
if %choice%==11 goto testcompatibility
if %choice%==h goto helpadhoc
if %choice%==x goto exitadhoc

echo ============================================
echo.
echo Pilihan tidak tersedia, silahkan pilih ulang
echo.
echo ============================================
pause
goto menu

:on
echo ============================================
echo ------------------ Aktif ------------------- 
echo ============================================
echo.
netsh wlan start hostednetwork
echo.
echo ============================================
pause
goto menu

:off
echo ============================================
echo ----------------- Nonaktif -----------------
echo ============================================
echo.
netsh wlan stop hostednetwork
echo.
echo ============================================
pause
goto menu

:create
echo ============================================
echo --------------- Buat Ad-Hoc ----------------
echo ============================================
echo.
netsh wlan stop hostednetwork >NUL
set set_ssid=
set /p set_ssid=Nama SSID: 
echo.
set set_pass=
set /p set_pass=Kata Sandi SSID: 
echo.
set set_autorun=
set /p set_autorun=Buat Ad-Hoc Autorun? (Yes/No): 
echo.
netsh wlan set hostednetwork mode=allow ssid="%set_ssid%" key="%set_pass%"
echo ============================================
echo ------------- Berhasil Dibuat --------------
echo ============================================
echo.
netsh wlan start hostednetwork
netsh wlan show hostednetwork setting=security
if "%set_autorun%"=="yes" (
 echo netsh wlan start hostednetwork > "%AppData%\Microsoft\Windows\Start Menu\Programs\Startup\Ad-Hoc_Autorun.cmd"
 echo Ad-Hoc dibuat Autorun
)
if "%set_autorun%"=="no" (
 del /f /q "%AppData%\Microsoft\Windows\Start Menu\Programs\Startup\Ad-Hoc_Autorun.cmd" >NUL
 echo Ad-Hoc dibuat tidak Autorun
)
echo.
echo ============================================
pause
goto menu

:status
echo ============================================
echo -------------- Status Ad-Hoc ---------------
echo ============================================
echo.
netsh wlan show hostednetwork
netsh wlan show hostednetwork setting=security
echo.
echo ============================================
pause
goto menu

:viewuser
@echo off
set hasClients=0
arp -a | findstr /r "192\.168\.[0-9]*\.[2-9][^0-9] 192\.168\.[0-9]*\.[0-9][0-9][^0-9] 192\.168\.[0-9]*\.[0-1][0-9][0-9]" >log_pengguna.tmp
arp -a | findstr /r "192\.168\.[0-9]*\.2[0-46-9][0-9] 192\.168\.[0-9]*\.25[0-4]" >>log_pengguna.tmp
for /F "tokens=1,2,3" %%i in (log_pengguna.tmp) do call :proses %%i %%j %%k
del log_pengguna.tmp
echo ============================================
echo ------------- Pengguna Ad-Hoc --------------
echo ============================================
echo.
if %hasClients%==0 echo ------------ Tidak ada pennguna ------------
if %hasClients%==1 (
 type result.tmp
 del result.tmp
)
echo.
echo ============================================
pause
goto menu

:proses
set VAR1=%1
ping -a %VAR1% -n 1 | findstr Pinging > log_ping.tmp
for /F "tokens=1,2,3" %%i in (log_ping.tmp) do call :proses2 %%i %%j %%k
del log_ping.tmp
goto :EOF

:proses2
set VAR2=%2
set VAR3=%3
set hasClients=1
echo %VAR2% %VAR3% >>result.tmp
goto :EOF

:viewpass
echo ============================================
echo ------------- Lihat Kata Sandi -------------
echo ============================================
echo.
netsh wlan show hostednetwork setting=security
echo.
echo ============================================
pause
goto menu

:changepass
echo ============================================
echo ------------- Ganti Kata Sandi -------------
echo ============================================
echo.
set /p set_pass="Kata Sandi Baru: "
netsh wlan refresh hostednetwork key="%set_pass%"
echo.
echo ============================================
pause
goto menu

:deleteadhoc
echo ============================================
echo ----------- Hapus Ad-Hoc Network -----------
echo ============================================
echo.
netsh wlan stop hostednetwork
net stop wlansvc
REG EXPORT "HKLM\SYSTEM\CurrentControlSet\Services\WlanSvc\Parameters\HostedNetworkSettings" "%systemdrive%\Users\%username%\Desktop\HostedNetworkSettings.BAK.reg"
REG DELETE "HKLM\SYSTEM\CurrentControlSet\Services\WlanSvc\Parameters\HostedNetworkSettings" /v HostedNetworkSettings
shutdown /t 0 /r /f
exit

:cleardnsnetwork
echo ============================================
echo ----------- Bersihkan Cache DNS ------------
echo ============================================
echo.
ipconfig /flushdns
ipconfig /displaydns
echo.
echo ============================================
pause
goto menu

:resetwinsock
echo ============================================
echo -------------- Reset Winsock ---------------
echo ============================================
echo.
netsh wlan stop hostednetwork
netsh winsock reset
net stop wlansvc
shutdown /t 0 /r /f
exit

:testcompatibility
echo ============================================
echo ------------ Test Compatibility ------------
echo ============================================
echo.
netsh wlan show drivers > "%systemdrive%\Users\%username%\Desktop\result.tmp"
find /i "hosted" "%systemdrive%\Users\%username%\Desktop\result.tmp"
DEL "%systemdrive%\Users\%username%\Desktop\result.tmp"
echo.
echo ============================================
pause
goto menu

:helpadhoc
echo ============================================
echo ----------------- Bantuan ------------------
echo ============================================
echo.
start https://ziixon93.blogspot.com
echo Jika Ad-Hoc tidak berjalan dengan baik harap
echo hubungi Twitter @iqbaralhakim atau bisa baca
echo tutorial di grup facebook INTERNET FREE ZONE
echo url grup facebook.com/groups/505099632951500
echo.
echo ============================================
pause
goto menu

:exitadhoc
echo ============================================
echo ------------------ Keluar ------------------
echo ============================================
echo.
taskkill /im cmd.exe /f
echo.
echo ============================================

:EOF


Terima kasih, semoga dapat dimanfaatkan dengan baik.