From: BNSGuy on 1 Apr 2010 22:27 On Mar 31, 9:02 am, "M Shafaat" <pop...(a)comhem.se> wrote: > Hi, > I wish to disable and enable my Local Area Connection using scripts. Can > anyone suggest a very simple script or command line using netsh etc for > doing this? > > My main objective is to prevent virus attacks from the Internet when the > machine is idle by disconnetcting my PC from the home network. > > Best regards, > M Shafaat Which is most important? dis- and re-enabling your connection? or doing so only when the computer is "idle"? The former is relatively simple and can be done using a variety of scripting techniques, or even batch files. I imagine the latter would not be terribly difficult (to some) either. I would think the most straight forward way would be to script an event sink that is triggered by the screen saver. (not personally sure exactly how to do that, but I've seen event triggered actions before). when the screen saver fires, the event sink would trigger the function to disable/re-enable the internet connection. A caveat would be that this would require the/a screen saver to be used. This would also allow the screen saver timeout to 'control' the actions of the connection dis-/re-enabler. If you are not running/able to run a screen saver, or want to define conditions other than what would trigger the screen saver... I'm sure it's possible, but currently out of my skill set.
From: M Shafaat on 2 Apr 2010 09:15 Hi again, I am really thankfull to all nice people who reply to my question. I mostly prefer to write a script that "programmatically" performs exactly the same actions that you can do manually as follows: From the "Network Connections" window, choose a specific connection e.g. "Local Area Connection 1", choose the menue "Disable this network device". Another script shall do the reverse, i.e. perform the menue "Enable this network device" on "Local Area Connection 1". I am sure that this is possible but I don't know how to do it. It seems likely to me that this is done easily by a command within "netsh". Best regards M Shafaat "BNSGuy" <daniel.a.murray(a)gmail.com> wrote in message news:c6cbd581-57ff-428f-87f8-16c7cf7ec006(a)v20g2000yqv.googlegroups.com... On Mar 31, 9:02 am, "M Shafaat" <pop...(a)comhem.se> wrote: > Hi, > I wish to disable and enable my Local Area Connection using scripts. Can > anyone suggest a very simple script or command line using netsh etc for > doing this? > > My main objective is to prevent virus attacks from the Internet when the > machine is idle by disconnetcting my PC from the home network. > > Best regards, > M Shafaat Which is most important? dis- and re-enabling your connection? or doing so only when the computer is "idle"? The former is relatively simple and can be done using a variety of scripting techniques, or even batch files. I imagine the latter would not be terribly difficult (to some) either. I would think the most straight forward way would be to script an event sink that is triggered by the screen saver. (not personally sure exactly how to do that, but I've seen event triggered actions before). when the screen saver fires, the event sink would trigger the function to disable/re-enable the internet connection. A caveat would be that this would require the/a screen saver to be used. This would also allow the screen saver timeout to 'control' the actions of the connection dis-/re-enabler. If you are not running/able to run a screen saver, or want to define conditions other than what would trigger the screen saver... I'm sure it's possible, but currently out of my skill set.
From: Pegasus [MVP] on 2 Apr 2010 17:20 "M Shafaat" <poppy2(a)comhem.se> wrote in message news:eXUyiam0KHA.840(a)TK2MSFTNGP06.phx.gbl... > Hi again, > I am really thankfull to all nice people who reply to my question. > > > > I mostly prefer to write a script that "programmatically" performs exactly > the same actions that you can do manually as follows: > From the "Network Connections" window, choose a specific connection e.g. > "Local Area Connection 1", choose the menue "Disable this network device". > > > > Another script shall do the reverse, i.e. perform the menue "Enable this > network device" on "Local Area Connection 1". > > > > I am sure that this is possible but I don't know how to do it. It seems > likely to me that this is done easily by a command within "netsh". > > > > Best regards > M Shafaat > Since you haven't received many scripting solutions, here is a batch file solution. With a small amount of effort you could translate it to a more robust VB Script although you would still need to shell out to the Console in order to execute devcon.exe. Note that different versions of devcon.exe are required for Intel or AMD CPUs. Device.bat ======= @echo off goto Start --------------------------------------------------- Enable or disable a device. Prerequisite: devcon.exe (http://download.microsoft.com/download/1/1/f/11f7dd10-272d-4cd2-896f-9ce67f3e0240/devcon.exe) 16.4.2006 FNL --------------------------------------------------- :Start SetLocal EnableDelayedExpansion set Adapter=Atheros AR5B93 Wireless Network Adapter echo. if /i "%1"=="enable" goto go if /i "%1"=="disable" goto go echo Syntax: Device enable / disable goto :eof :go set HWID=x set count=0 set found=no devcon hwids "PCI\*" > "%temp%\device.txt" for /F "tokens=*" %%* in ('type "%temp%\device.txt"') do ( set /a count=!count! + 1 if /i "%%*"=="Name: %Adapter%" set found=yes& set count=1 if !found!==yes if !count!==3 set HWID=%%* ) if %found%==yes ( echo HWID=!HWID! devcon %1 "!HWID!" ) else ( echo Device "%Adapter%" not found. ) endlocal del "%temp%\device.txt"
From: The Pinky on 2 Apr 2010 19:54 Thx, cool tool... i am sure with that its possible to realise interesting scripts :) in the case here i am sure it should be possible to read out from WMI the networkcards and mix the Info with registry HKLM\System\currentControlSet\enum\PCI and get so the Hardware ID you want to disable with the Devcon Tool :) nice nice "BigDaddyJim" <hungerfordj(a)gmail.com> schrieb im Newsbeitrag news:95a10dc8-7fa3-4712-a834-45d23c7f87f8(a)g11g2000yqe.googlegroups.com... On Mar 31, 5:23 pm, "The Pinky" <Edi...(a)g-websys.de> wrote: > maybe you have success with the DOS Command: > ipconfig /release > and > ipconfig /renew > if you retrieve your IP Adresse by DHCP this should disconnect you and > after > that reconnect... > you could execute that Dos Command in a vbs script... > > "M Shafaat" <pop...(a)comhem.se> schrieb im > Newsbeitragnews:u1HZ2JN0KHA.2196(a)TK2MSFTNGP05.phx.gbl... > > > > > Hi, > > I wish to disable and enable my Local Area Connection using scripts. Can > > anyone suggest a very simple script or command line using netsh etc for > > doing this? > > > My main objective is to prevent virus attacks from the Internet when the > > machine is idle by disconnetcting my PC from the home network. > > > Best regards, > > M Shafaat- Hide quoted text - > > - Show quoted text - You might try a script with the DEVCON command-line exe. http://support.microsoft.com/kb/311272 It'll allow you to enable/disable hardware of a specific ID in a script. Jim
From: M Shafaat on 2 Apr 2010 20:21 Hi again, The solution from Pegasus seems interesting to test, I would try it, thank a lot to all. Regards M Shafaat
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: help with the script Next: Extract words from a .dita file |