Students Empire

Learn Something New
Home


Close the port in windows machine


In this post i am show the code from the how to close the ports in windows from the vbs script and batch file programming .


In the below post you can try at your own risk and enjoy programming .


VBS Script

		set ss = createobject("wscript.shell")
		set ws = wscript
		dim PORT
		PORT = InputBox("Enter the port you wish to close:")
		ss.run "netsh.exe"
		ws.sleep 1000
		ss.sendkeys "firewall delete portopening TCP " & PORT
		ss.sendkeys "{enter}"
		ws.sleep 500
		'ss.sendkeys "exit"
		'ss.sendkeys "{enter}"
		

Note : In this above post you can copy and paste from the notepad and save this file from the .vbs and run at your own risk .




Batch File programming


		@echo off
		title Port Closer
		echo Port Closer
		echo.
		set /p port=Type the port number you wish to close here:
		netsh firewall delete portopening TCP %port%
		msg /w * Port %port% has been closed.
		exit
		


Note : In this above post you can copy and paste from the notepad and save this file from the .bat and run at your own risk.