Sign in to follow this  
Followers 0
coucou

How to block all connexion during software install

11 posts in this topic

Hi,

How to block any connexion toward outside during a software installation.

In fact, i wrote a script for silent install software, and i have to manually disable my wireless connexion in order to install it then manually enable the wireless connexion after that software installed.

BTW, i noticed that NO iexplorer process opened.

Regards

coucou

Share this post


Link to post
Share on other sites



Hi,

How to block any connexion toward outside during a software installation.

In fact, i wrote a script for silent install software, and i have to manually disable my wireless connexion in order to install it then manually enable the wireless connexion after that software installed.

BTW, i noticed that NO iexplorer process opened.

Regards

coucou

Yee I am looking as well for this kind of "tool"

Share this post


Link to post
Share on other sites

Well, according to the "MS Scripting Guys", you can't.

Unless, that is, you are running Vista:

$RET = _NetworkEnable()
MsgBox(64, "Result", "$RET = " & $RET & @CRLF & _
        "@error = " & @error & @CRLF & _
        "@extended = " & @extended)
        
; -----------------------------------------------------
; Function _NetworkEnable()
;   Enables/Disables one or all network adapters
;   Call with:  _NetworkEnable( [$iEnable [, $sName [, $sComputer]]] )
;   Where:  $iEnable (optional):  1 (default) = Enable, 0 = Disable
;           $sName (optional):  The name of an adapter, or an empty string for all (default)
;           $sComputer (optional):  The name of the computer to operate on.  Default = "."
;   On success returns 1 and @extended = count of adapters operated on
;   On failure retruns 0 and sets @error:
;       @error = 1  Failed to connect to WMI
;       @error = 2  Query failed to return a collection
;       @error = 3  No matching adapter names
; Note:  The .enable and .disable methods are not available on versions of Windows before Vista.
; -----------------------------------------------------
Func _NetworkEnable($iEnable = 1, $sName = "", $sComputer = ".")
    Local $sNetEnabled = "'False'", $objItem, $sObjName = "", $iCount = 0
    If Not $iEnable Then $sNetEnabled = "'True'"
    
    Local $objWMIService = ObjGet("winmgmts:\\" & $sComputer & "\root\CIMV2")
    If IsObj($objWMIService) Then
        Local $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapter Where NetEnabled = " & $sNetEnabled)
        If IsObj($colItems) Then
            For $objItem In $colItems
                $sObjName = $objItem.Name
                If $sName = "" Or $sName = $sObjName Then
                    $iCount += 1
                    ConsoleWrite("Name: " & $sObjName & @LF)
                    ConsoleWrite("Description: " & $objItem.Description & @LF)
                    If $iEnable Then
                        $objItem.Enable
                    Else
                        $objItem.Disable
                    EndIf
                Else
                    ContinueLoop
                EndIf
            Next
            If $iCount Then
                ; Success, @extended = count
                Return SetError(0, $iCount, 1)
            Else
                ; No matching adapters found
                Return SetError(3, 0, 0)
            EndIf
        Else
            ; Win32_NetworkAdapter query did not return a collection
            Return SetError(2, 0, 0)
        EndIf
    Else
        ; Faile to connect to WMI
        Return SetError(1, 0, 0)
    EndIf
EndFunc   ;==>_NetworkEnable

I don't have (or want) Vista, so I can't test that adaptation... Let me know if it works.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I don't have Vista neither

So... Is there NO issue? :)

coucou

Share this post


Link to post
Share on other sites

PsaltyDS - I don't really need it right now, but do see future purposes. I will test it when I get home this evening, after soccer :) -Will let you know . . .

Share this post


Link to post
Share on other sites

was just thinking - - why disable the network connection?

Why not just check all open ports and write to a file. Have a couple buttons on a gui. One Close, one Open. When you press close, all ports that are open are written. When you press open, the file is read to array and all ports that are in the file are unblocked . . .

Would this not work?

Share this post


Link to post
Share on other sites

From reading the code it looks like it records what is open and disables it. Not working on vista :)

$Ret = 1

@error = 0

@Extended = 1

let me know if you need any more testing~

Share this post


Link to post
Share on other sites

From reading the code it looks like it records what is open and disables it. Not working on vista :P

$Ret = 1

@error = 0

@Extended = 1

let me know if you need any more testing~

Well, the return data says it worked:

; On success returns 1 and @extended = count of adapters operated on

$RET = 1 means success, and @extended indicates 1 adapter was operated on.

Did you check to see if the adapter was, in fact, enabled or disabled after running it?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

ha! -of course I did. I have two, one lan cable, one wireless. I was using the wireless, never went down. The lan cable was not plugged, but I did have network connections open and it never changed to disabled either :P sorry!

Still wondering however, I know that you can open a port with autoit. -seen code to do it. Can you disable them also? If so, why not convert your code to ports instead of network adapters? Then you have a xp/vista code that saves open port data, and disables them. Another button acts as a "recall" closed ports to active . . . -Then again maybe I'm dreaming magic coding here . . . :)

Share this post


Link to post
Share on other sites

Well,... looking at the WEB I found this:

Devcon.exe

http://support.microsoft.com/default.aspx?...;NoWebContent=1

You will nedd to intall devcon into your windows then

devcon find PCI *

devcon disable PCI\.............

devcon enable PCI\.............

devcon status PCI\..........

you can use as well this: http://www.autoitscript.com/forum/index.ph...amp;hl=compinfo

anyone got easier ???

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

if you just want to stop all internet connections then do:

#include<process.au3>
_rundos("ipconfig /release")

and to re-enable

#include<process.au3>
_rundos("ipconfig /renew")

edit: this blocks all traffic, not just outgoing just so you know..

Edited by EvAsion

Share this post


Link to post
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
Sign in to follow this  
Followers 0