Jump to content

How to Disable "Hamachi Network Interface"?


iXX
 Share

Recommended Posts

Might help: http://www.autoitscript.com/forum/index.php?showtopic=118205

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Because that scripts don't work for me (I don't know how to edit them for my Czech OS language), I have solved this by very, very jerkily way:

1. I open the Network Connection folder.

2. Right click to "Hamachi" interface, drag it to my QuickLaunch panel and make shortcut there.

3. For disabling Hamachi adapter, I use this: ;)

$MousePos = MouseGetPos()  ; Save actual mouse position
MouseClick("right", 116, 754, 1, 0)  ; Click to QiuckLaunch Hamachi shortcut to show menu
Sleep(50)
Send("{DOWN}")  ; Select first from top item of menu (Disable)
Sleep(50)
Send("{ENTER}")  ; Disable!
Sleep(50)
MouseMove($MousePos[0], $MousePos[1], 0)  ; Return mouse to original location

I know, this is maybe the badest solution ever, I hope someone will translate proper scripts to my os language... :)

Edited by iXX
Link to comment
Share on other sites

I need a better script to disable Hamachi Network Interface. That one above is too absurd... ;)

I am trying scripts from: http://www.autoitscript.com/forum/index.php?showtopic=118205

But I dont know how to modify them EXACTLY.

Here is what I think is needed:

My OS is: WinXP SP3 Czech

Folder "Network Connection" = "Síťová připojení"

Name of network adapter: "Hamachi"

Description of network adapter: "Hamachi Network Interface"

"En&able" = "&Povolit"

"Disa&ble" = "&Zakázat"

But I don't know how to edit this line:

Case StringInStr("0409,0809,0c09,1009,1409,1809,1c09,2009,2409,2809,2c09,3009,3409", @OSLang) ; English (United States)
Where can I get this numbers for Czech language?

So, how to edit this one?:

#RequireAdmin


Func AdapterKill($AdaptDescription, $ConnectionName, $bEnable = false)
    ;$AdaptDescription = "' '"  ;for Vista/Win7 Actual Adapter Name must be single quoted inside double-quotes
    ;$ConnectionName = " " ;for PreVista Connection Name in Net Connections
    
    if @OSType<>"WIN32_NT" then
        SetError(1)
    endif
    if @OSVersion="WIN_2000" then
        $strFolderName = "Network and Dial-up Connections"
        PreVistaDisable($ConnectionName,$strFolderName,$bEnable)
        Return 0
    elseif StringInStr(@OSVersion, "WIN_XP") then
        $strFolderName = "Network Connections"
        PreVistaDisable($ConnectionName,$strFolderName,$bEnable)
        Return 0
    else
        VistaDisable($AdaptDescription,$bEnable)
        Return 0
    endif
EndFunc


Func VistaDisable($Adapter, $bEnable = false)
    $objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2")
    If $objWMIService.ExecQuery("SELECT Description FROM Win32_NetworkAdapter WHERE NetEnabled = True AND Description = " & $Adapter).Count > 0 Then
        $colItems = $objWMIService.ExecQuery("SELECT Description FROM Win32_NetworkAdapter WHERE NetEnabled = True AND Description = " & $Adapter)
        If IsObj($colItems) Then
            For $objItem In $colItems
                If $bEnable = False Then
                    $objItem.Disable()
                Else
                    $objItem.Enable()
                EndIf
                
                Next
            Return 0
        EndIf           
    EndIf
EndFunc

Func PreVistaDisable($oLanConnection,$strFolderName, $bEnable = false)
    ;$bEnable = false             ; Change this to 'false' to DISABLE the network adapter

    Select 
        Case StringInStr("0409,0809,0c09,1009,1409,1809,1c09,2009, 2409,2809,2c09,3009,3409", @OSLang) ; English (United States)
           $strEnableVerb  = "En&able"
           $strDisableVerb = "Disa&ble"

    ; Add here the correct Verbs for your Operating System Language
    EndSelect


    ;Virtual folder containing icons for the Control Panel applications. (value = 3)
    Const $ssfCONTROLS = 3 

    $ShellApp = ObjCreate("Shell.Application")
    $oControlPanel = $shellApp.Namespace($ssfCONTROLS)


    ; Find 'Network connections' control panel item
    $oNetConnections=""

    For $FolderItem in $oControlPanel.Items
        If $FolderItem.Name = $strFolderName then
            $oNetConnections = $FolderItem.GetFolder
            Exitloop
        Endif
    Next

          
    If not IsObj($oNetConnections) Then
        SetError(1)
    EndIf
            

    For $FolderItem In $oNetConnections.Items
        If StringLower($FolderItem.Name) = StringLower($oLanConnection) Then
            $oLanConnection = $FolderItem
            Exitloop
        EndIf
    Next

    If not IsObj($oLanConnection) Then
        SetError(1)
    EndIf

    $oEnableVerb=""
    $oDisableVerb=""

    For $Verb In $oLanConnection.Verbs
     If $Verb.Name = $strEnableVerb Then
       $oEnableVerb = $Verb
     EndIf
     If $Verb.Name = $strDisableVerb Then
       $oDisableVerb = $Verb
     EndIf
    Next

    If $bEnable then
     If IsObj($oEnableVerb) Then $oEnableVerb.DoIt  ; Enable network card
    Endif

    If not $bEnable then
     If IsObj($oDisableVerb) Then $oDisableVerb.DoIt; Disable network card
    EndIf

    Sleep(1000)
EndFunc
Link to comment
Share on other sites

SOLVED!

So, if anyone need script to DISABLE Hamachi Network Interface on CZECH WinXP (and maybe others windows versions), use this modificated one:

#RequireAdmin


Func AdapterKill($AdaptDescription, $ConnectionName, $bEnable = false)
    ;$AdaptDescription = "' '"  ;for Vista/Win7 Actual Adapter Name must be single quoted inside double-quotes
    ;$ConnectionName = " " ;for PreVista Connection Name in Net Connections
    
    if @OSType<>"WIN32_NT" then
        SetError(1)
    endif
    if @OSVersion="WIN_2000" then
        $strFolderName = "Network and Dial-up Connections"
        PreVistaDisable($ConnectionName,$strFolderName,$bEnable)
        Return 0
    elseif StringInStr(@OSVersion, "WIN_XP") then
        $strFolderName = "Síťová připojení"
        PreVistaDisable($ConnectionName,$strFolderName,$bEnable)
        Return 0
    else
        VistaDisable($AdaptDescription,$bEnable)
        Return 0
    endif
EndFunc


Func VistaDisable($Adapter, $bEnable = false)
    $objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2")
    If $objWMIService.ExecQuery("SELECT Description FROM Win32_NetworkAdapter WHERE NetEnabled = True AND Description = " & $Adapter).Count > 0 Then
        $colItems = $objWMIService.ExecQuery("SELECT Description FROM Win32_NetworkAdapter WHERE NetEnabled = True AND Description = " & $Adapter)
        If IsObj($colItems) Then
            For $objItem In $colItems
                If $bEnable = False Then
                    $objItem.Disable()
                Else
                    $objItem.Enable()
                EndIf
                
                Next
            Return 0
        EndIf           
    EndIf
EndFunc

Func PreVistaDisable($oLanConnection,$strFolderName, $bEnable = false)
    ;$bEnable = false             ; Change this to 'false' to DISABLE the network adapter

    Select 
        Case StringInStr("0405,0409,0809,0c09,1009,1409,1809,1c09,2009, 2409,2809,2c09,3009,3409", @OSLang) ; English (United States)
           $strEnableVerb  = "&Povolit"
           $strDisableVerb = "&Zakázat"

    ; Add here the correct Verbs for your Operating System Language
    EndSelect


    ;Virtual folder containing icons for the Control Panel applications. (value = 3)
    Const $ssfCONTROLS = 3 

    $ShellApp = ObjCreate("Shell.Application")
    $oControlPanel = $shellApp.Namespace($ssfCONTROLS)


    ; Find 'Network connections' control panel item
    $oNetConnections=""

    For $FolderItem in $oControlPanel.Items
        If $FolderItem.Name = $strFolderName then
            $oNetConnections = $FolderItem.GetFolder
            Exitloop
        Endif
    Next

          
    If not IsObj($oNetConnections) Then
        SetError(1)
    EndIf
            

    For $FolderItem In $oNetConnections.Items
        If StringLower($FolderItem.Name) = StringLower($oLanConnection) Then
            $oLanConnection = $FolderItem
            Exitloop
        EndIf
    Next

    If not IsObj($oLanConnection) Then
        SetError(1)
    EndIf

    $oEnableVerb=""
    $oDisableVerb=""

    For $Verb In $oLanConnection.Verbs
     If $Verb.Name = $strEnableVerb Then
       $oEnableVerb = $Verb
     EndIf
     If $Verb.Name = $strDisableVerb Then
       $oDisableVerb = $Verb
     EndIf
    Next

    If $bEnable then
     If IsObj($oEnableVerb) Then $oEnableVerb.DoIt  ; Enable network card
    Endif

    If not $bEnable then
     If IsObj($oDisableVerb) Then $oDisableVerb.DoIt; Disable network card
    EndIf

    Sleep(1000)
EndFunc
 

AdapterKill ("", "Hamachi")
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...