Saturday, September 27, 2014

Enable / Disable File And Printer Sharing On Hamachi Network Adapter

I recently found Hamachi service running in the windows taskbar on my sons PC
This allows him to play Minecraft and other games together with his friends.
Sounds safe but that is if you trust his friends.
The problem with doing it this way is you are bypassing your modem security rules and firewall  restrictions thus allowing them access to your files and printers etc.

First thing I did was to disable file and printer sharing on the Hamachi network adapter

Go to Start
Control Panel
Network And Internet
Network And Sharing Center
Change adapter settings
You will see local area connections don’t touch these
Look for the Hamachi network
Right click on the Hamachi network connection
Then properties
Then untick client for Microsoft networks and also untick file and printer sharing for Microsoft networks
Press OK

I would feel better knowing the adapter was disabled so i decided to create a batch file that would enabled or disabled this for him.

I found a script on the net which I modified to do what i wanted.

Firstly you need to know is the name of your Hamachi adapter

Go to Start, Control Panel, Network And Internet, Network And Sharing Center

Click on Change adapter settings, all your network adapters are shown

Take note of the name of the Hamachi adapter.

Enter this name where I have highlighted (BLUE) my Hamachi name in the script below.


To Disable


REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
netsh interface set interface "Hamachi" Disable"


Copy into a txt document and then rename to disable.bat



To Enable


REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
netsh interface set interface "Hamachi" enable


Copy into a txt document and then rename to enable.bat




Disable: https://drive.google.com/file/d/0BwjqRgkVKt1IWWVpQXBra2FSdk0/edit?usp=sharing


Enable : https://drive.google.com/file/d/0BwjqRgkVKt1IWk1fWmViMUMyREE/edit?usp=sharing















No comments: