smashly Posted July 17, 2008 Share Posted July 17, 2008 I did something similar to this a month ago. But you'd probly have the same problem for non english os.I was thinking of adding muti language support, but no one seemed to interested in the functions so I dropped it.Disable, Enable or Repair a Local network connection. Link to comment Share on other sites More sharing options...
KimslanD Posted July 17, 2008 Share Posted July 17, 2008 smashly yours works! muttley No errors so far Link to comment Share on other sites More sharing options...
KimslanD Posted July 17, 2008 Share Posted July 17, 2008 Sorry for double post (once I used edit my reply, and it just came up garbled, so I don't trust it) Anyway, Yes it works, but I thought hang on if I use your one, on another computer I have to run the gui again, to create the new Stop/Start network. Hmm I don't like that. My idea for this is to run it on any computer without any disruption (or addition) of any other files Ideally I just need one program (like yours) so as I don't click on one to start it and one to stop it. Anyway you guys rock muttley I'll continue to check here (at this thread) for any further updates. I'm still also highly interested in Tlem script (which does seem to work on any computer - but still has errors) smashly, if you want to update yours to gui that you can disable directly from gui (and enable from gui) that would be grand Here's hopeing (or is that hoping?) Kim Link to comment Share on other sites More sharing options...
smashly Posted July 17, 2008 Share Posted July 17, 2008 Sorry for double post (once I used edit my reply, and it just came up garbled, so I don't trust it)Anyway, Yes it works, but I thought hang on if I use your one, on another computer I have to run the gui again, to create the new Stop/Start network. Hmm I don't like that.My idea for this is to run it on any computer without any disruption (or addition) of any other filesIdeally I just need one program (like yours) so as I don't click on one to start it and one to stop it.Anyway you guys rock muttley I'll continue to check here (at this thread) for any further updates.I'm still also highly interested in Tlem script (which does seem to work on any computer - but still has errors)smashly, if you want to update yours to gui that you can disable directly from gui (and enable from gui) that would be grand Here's hopeing (or is that hoping?)KimGlad it works for you,The idea was for a user to use the udf for what they want, the gui was only an example of use of the udf.If I was going to use a gui to disable, enable then I'd probably just use windows native interface instead Maybe you should have a go at making a gui to suite your own needs since you now have some basic ideas on how to do what your after Cheers Link to comment Share on other sites More sharing options...
KimslanD Posted July 17, 2008 Share Posted July 17, 2008 I'd probably just use windows native interface insteadYou mean Net Stop and so forth?No not that way It needs to be a file, not a shortcutThis is why yours would be ideal (as either a single file <--which it is already)But not as your program running another variable (like the desktop link to Network link)It needs to be just a single program, that does it allie To run Windows Notepad, we don't run explorer: then the PID then some variable then some switchWe just run Notepad.Therefore to enhance your program, the gui also requires a disable and enable option, within itMaybe you should have a go at making a gui to suite your own needsLets face it I can't (presently) Nor do I think I could honestly learn all this, there's even a forum (this one!) for advanced members who still require help. Not only that, its been done already. By you and TlemTo be quite clear about all of this.A standalone program to Enable/Disable the network (only) Does NOT exist on the web, anywhere!Some come close, but believe it or not, you guys are closer (way closer)I have attended thousands of Homes and Business, I have supported thousands on the webThe option to have a program (not individualized) that can quickly disable the net (simply) then re-enable it (simply) would be utilized by everyone! Hang on I'll just go get a coffee (should I turn off the computer? It is on the net? Unattended!)Personal Firewalls can do it, but if I want to run local games or high end graphics, I don't want my firewall on (or net) at all.Should I defrag whilst being online? There's just too many reasons why it should exist. Which it doesn't!An autoitscript can do it (it even creates an exe and an icon) A gui would be perfect (but not compulsory)But the autoitscript would have to be standalone. Shouldn't they all be? That's the point isn't it?Does anyone understand me? Link to comment Share on other sites More sharing options...
smashly Posted July 17, 2008 Share Posted July 17, 2008 You mean Net Stop and so forth?No not that way It needs to be a file, not a shortcutThis is why yours would be ideal (as either a single file <--which it is already)But not as your program running another variable (like the desktop link to Network link)It needs to be just a single program, that does it allie To run Windows Notepad, we don't run explorer: then the PID then some variable then some switchWe just run Notepad.Therefore to enhance your program, the gui also requires a disable and enable option, within itLets face it I can't (presently) Nor do I think I could honestly learn all this, there's even a forum (this one!) for advanced members who still require help. Not only that, its been done already. By you and TlemTo be quite clear about all of this.A standalone program to Enable/Disable the network (only) Does NOT exist on the web, anywhere!Some come close, but believe it or not, you guys are closer (way closer)I have attended thousands of Homes and Business, I have supported thousands on the webThe option to have a program (not individualized) that can quickly disable the net (simply) then re-enable it (simply) would be utilized by everyone! Hang on I'll just go get a coffee (should I turn off the computer? It is on the net? Unattended!)Personal Firewalls can do it, but if I want to run local games or high end graphics, I don't want my firewall on (or net) at all.Should I defrag whilst being online? There's just too many reasons why it should exist. Which it doesn't!An autoitscript can do it (it even creates an exe and an icon) A gui would be perfect (but not compulsory)But the autoitscript would have to be standalone. Shouldn't they all be? That's the point isn't it?Does anyone understand me?I understand what you want, but I just can't bring myself to make it that easy just as of yet...lolMyself and most others here on the forum like to offer help to those that are willing to help themselves.By this I mean that a user tries to at least to have a go and try writing some code that suites their own needs.When they get stuck then they post what they've tried and usually someone will pitch in and try and help.For me to add a enable/disable button to that example gui I wrote would probably take under 2 mins.But where's the fun in that, when I'd rather see you give it at least a try and pick up a little knowledge along the way and you'd probably use the knowledge to help someone else when they're stuck in their effort of code... (Chain effect)So saying what's the point cause someone has already ahead of you in the learning curve game of writing code isn't really showing any spark.That spark I refer to is what makes the AutoIt community.So commit some effort , the tools are at your disposal, the ppl are eager to help, the rest is upto you for the time being muttleyCheers Link to comment Share on other sites More sharing options...
KimslanD Posted July 17, 2008 Share Posted July 17, 2008 I see, how much money do you want muttley Only joking I understand what you mean, but I have come from a support forum as a top Guru (not in autoit obviously) And when a new member comes on and says my network doesn't work (or a million other questions) We don't teach them, we just provide the direct answer. Like run this: cmd /c ipconfig /all >Desktop\ipconfig.txt We're not about to say, well cmd stands for command prompt and ...... We'd be there all day! We get the user fixed, and they're happy But I suppose I'll try (I'd say a month or two and I'll get there But writing going down on an angle, seems so strange! Link to comment Share on other sites More sharing options...
Tlem Posted July 20, 2008 Share Posted July 20, 2008 (edited) I have updated my code : http://www.autoitscript.fr/forum/viewtopic.php?p=7329#p7329Work on French W2K, WIN XP (and US), WIN 2003, Vista and probably to WIN2K8.Not sure on one verb for English W2K (see line 319).Adding :- _NetCC("connection name", 4) => Return state of connection.- _NetCC("connection name", 3) => Repair connection.- _NetCC("connection name", 2) => Toggle connection.- _NetCCGetList() => Return an array of connections list.Tanks to Kim for is testing. muttley Edited July 21, 2008 by Tlem Best Regards.Thierry Link to comment Share on other sites More sharing options...
ShminkyBoy Posted October 8, 2008 Share Posted October 8, 2008 (edited) is there a dll call that can be used to do this instead? Because using the Shell.Application object's functionalities will only work if a user shell is initialized, correct? ie- a user must be logged in to use this udf, since accessing the Shell.Application object requires a user logging in and activating the shell... right? Just curious, i've been all over msdn and am rather super confused as to what exactly to look for as far as attempting using dllcall() to do this instead.. The reason I ask is because I am writing a script that will be run as as service and i need to be able to control the nic to enable, disable and repair it whether there is or is not a user logged on to the PC. This doesn't appear to work unless there is a user logged in when the Shell.Application object is used. any ideas? Edited October 8, 2008 by ShminkyBoy Urban Terror - ioUrban Terror website Like-yea Link to comment Share on other sites More sharing options...
LarryDalooza Posted October 8, 2008 Share Posted October 8, 2008 NETSH.EXE command line utility... off to google with you. Lar. AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
ShminkyBoy Posted October 9, 2008 Share Posted October 9, 2008 NETSH.EXE command line utility... off to google with you.Lar.Thanks for the suggestion Lar, but I can't seem to find any documentation for the Ifmon.dll file itself, the part of netsh that I want to make use of with dllcall()..I would prefer not to have to use an external app in the script- making the dllcall() directly would be better, no?I've gone quite a bit of googling and searching the forums, with no luck =( Urban Terror - ioUrban Terror website Like-yea Link to comment Share on other sites More sharing options...
LarryDalooza Posted October 9, 2008 Share Posted October 9, 2008 (edited) The exports of Ifmon.dll tell me it is not what you want... perhaps IPHLPAPI.DLL is what you want... but NETSH.EXE with @SW_HIDE is the shortest distant between two points.Lar.http://msdn.microsoft.com/en-us/library/aa366071(VS.85).aspx Edited October 9, 2008 by LarryDalooza AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
archrival Posted December 9, 2008 Share Posted December 9, 2008 The exports of Ifmon.dll tell me it is not what you want... perhaps IPHLPAPI.DLL is what you want... but NETSH.EXE with @SW_HIDE is the shortest distant between two points.Lar.http://msdn.microsoft.com/en-us/library/aa366071(VS.85).aspxUnforutunately netsh doesn't disable the connection on Windows XP. Microsoft KB Link to comment Share on other sites More sharing options...
S0mbre Posted March 26, 2009 Share Posted March 26, 2009 Hi All!I'm a newcomer to AutoIt (got wise to it yesterday), but have already managed to practice some coding. Since one of my urging tasks was similar to this one discussed here (toggle LAN connection on and off), I spent some time trying to script that. I've tried some solutions offered here: http://www.autoitscript.com/forum/index.php?showtopic=12034 and here: http://www.autoitscript.com/forum/index.php?showtopic=12645, but they didn't work too fine. So I've found what seems a more robust solution. I don't know if it works on any other OSs other than mine (Windows XP SP3), but it seems to be entirely independent of local languages (it doesn't use "verbs" and system folder names). I just found a free Microsoft product - a console-run device manager called devcon (try googling it or searching in MSDN). This tool can enable / disable any device using WinAPI and given the device's ID (a string value). So my task in AutoIt boiled down to writing a wrapper.And here it is:expandcollapse popup#Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=LAN_Control_ENG.exe #AutoIt3Wrapper_Run_Tidy=y #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> Global Const $DEVCON = @ScriptDir & "\devcon.exe" Func Connect($bConnect = True) If $bConnect = True Then If ShellExecute($DEVCON, "enable ms_pschedmp", "", "", @SW_HIDE) = 1 Then; "ms_pschedmp" is the LAN devices ID Return True Else Return False EndIf Else If ShellExecute($DEVCON, "disable ms_pschedmp", "", "", @SW_HIDE) = 1 Then; "ms_pschedmp" is the LAN devices ID Return True Else Return False EndIf EndIf EndFunc ;==>Connect $gui = GUICreate("LAN Control", 155, 80) $gui_label = GUICtrlCreateLabel("Choose option:", 30, 10) $gui_b_OK = GUICtrlCreateButton("Enable LAN", 5, 40, 70, 30) $gui_b_Cancel = GUICtrlCreateButton("Disable LAN", 80, 40, 70, 30) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $gui_b_OK If Connect() Then MsgBox(64, "OK!", "LAN enabled!") ExitLoop Else MsgBox(48, "Error!", "An error occurred!") ExitLoop EndIf Case $msg = $gui_b_Cancel If Connect(False) Then MsgBox(64, "OK!", "LAN disabled!") ExitLoop Else MsgBox(48, "Error!", "An error occurred!") ExitLoop EndIf Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEndHere's a RAR file containing the above source code, a compiled EXE, and devcon (for i386 systems): http://narod.ru/disk/7051598000/LanControl.rar.htmlPlease comment! Link to comment Share on other sites More sharing options...
ShminkyBoy Posted May 12, 2009 Share Posted May 12, 2009 The exports of Ifmon.dll tell me it is not what you want... perhaps IPHLPAPI.DLL is what you want... but NETSH.EXE with @SW_HIDE is the shortest distant between two points. Lar. http://msdn.microsoft.com/en-us/library/aa366071(VS.85).aspx Unforutunately netsh doesn't disable the connection on Windows XP. Microsoft KB As noted by archrival, this unfortunately does not work. =( Please comment! nice wrapper for devcon =) I was hoping for something native Autoit, perhaps using some dll calls. After poking about i did an export of netsh.dll's functions and I tried something like this: #include <Constants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $hdll = DllOpen ('netshell.dll') MsgBox(0,'',$hdll) $value = DllCall ($hdll, 'none', 'RepairConnection') MsgBox(0,'',$value) DllClose($hdll) but this crashes autoit (I'm using 3.3.0.0).. Am I doing this dll call wrong Lar? Urban Terror - ioUrban Terror website Like-yea Link to comment Share on other sites More sharing options...
toxicvn Posted May 13, 2009 Share Posted May 13, 2009 you try : netsh interface set interface <interface name> DISABLED For example to disable an interface with its default name Local Area Connection, run: netsh interface set interface Local Area Connection DISABLED To enable the interface, you'd then run: netsh interface set interface Local Area Connection ENABLED Link to comment Share on other sites More sharing options...
ShminkyBoy Posted May 13, 2009 Share Posted May 13, 2009 (edited) you try :netsh interface set interface <interface name> DISABLEDFor example to disable an interface with its default name Local Area Connection, run:netsh interface set interface Local Area Connection DISABLEDTo enable the interface, you'd then run:netsh interface set interface Local Area Connection ENABLEDThank you, toxicvn, but archrival has already given proof that this is not the case:Unforutunately netsh doesn't disable the connection on Windows XP. Microsoft KBDedicated interfaces cannot be connected, disconnected, enabled, or disabled. This behavior occurs because the Netshell tool treats network adapters as dedicated interfaces.I think the dllcall would work, if i could learn what parameters the call was expecting; i did some googling for netshell.dll, and so i've seen mention of a thread on a forum somewhere that shows the dllcall, unfortunately the site that allegedly had this example no longer exists now =( Edited May 13, 2009 by ShminkyBoy Urban Terror - ioUrban Terror website Like-yea Link to comment Share on other sites More sharing options...
CtrlX Posted April 21, 2011 Share Posted April 21, 2011 Another way to disable/enable the network adapter #include <GuiConstantsEx.au3> GuiCreate("NIC Switch", 230, 50) $GUI_ENABLE_BUTTON = GuiCtrlCreateButton("Enable", 10, 10, 100, 30) $GUI_DISABLE_BUTTON = GuiCtrlCreateButton("Disable", 120, 10, 100, 30) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_ENABLE_BUTTON Run("netsh.exe interface set interface ""Local Area Connection"" ENABLE") Case $msg = $GUI_DISABLE_BUTTON Run("netsh interface set interface ""Local Area Connection"" DISABLE") EndSelect WEnd NightHawk56 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now