View Single Post
  #32  
Old July 21st 09, 06:21 PM posted to microsoft.public.windowsxp.network_web,microsoft.public.windowsxp.general
Pegasus [MVP]
external usenet poster
 
Posts: 2,361
Default Ethernet adapter interfering with Mouse


wrote in message
...
On Jul 20, 4:33 am, "Pegasus [MVP]" wrote:
wrote in message

...
On Jul 19, 6:25 pm, "Pegasus [MVP]" wrote:

Yes, it's possible to enable/disable your network adapter as part of
your
startup process even though this is a clumsy solution. If you cannot
resolve
the issue in a more elegant way then I would like you to post the exact
name
of your network adapter. You will find it in the Control Panel / Network
Connections in the column headed "Device Name". As an example, the name
of
my adapter is "Broadcom NetXtreme Fast Ethernet".


It is called "Intel(R) PRO/1000 PL Network Connection"

=============

OK, here you go:
1. Create a folder c:\Tools.
2. Download devcon.exe
fromhttp://download.microsoft.com/download/1/1/f/11f7dd10-272d-4cd2-896f-...
and put it into the folder c:\Tools.
3. Copy & paste the code below into the file c:\Tools\DeviceEnabler.bat.
Make sure to use the .bat extension - it won't work with a .txt extension.
Do NOT retype the code - you're likely to make mistakes.
4. Remove all line numbers.
5. Click Start / Run
6. Type the three letters cmd and click OK.
7. Type this command: c:\Tools\DeviceEnabler.
You should see two messages: One that says that your adapter was
disabled, the other that it was enabled.
8. Adjust the delay value in Line 12 to suit your environment. Perhaps you
can reduce it to 1 or 2 seconds.
You now have two options to execute the batch file automatically.
9a. By means of a logon script. This method is simpler but it creates a
black console screen at logon time. Using notepad.exe, create the file
c:\documents and settings\all users\start
menu\programs\startup\netlogon.bat
and put these lines inside:
@echo off
call c:\Tools\DeviceEnabler.bat
9b. By means of a scheduled task. This method is a little more complex but
it works invisibly in the background. Open the Control Panel, then the
Task
Scheduler, then create a new task with the following properties:
- Name of Task: Device Enabler.
- Command line: c:\Tools\DeviceEnabler.bat
- Account to run under: Administrator
- Schedule: To run at logon time.

[01] @echo off
[02] goto Start
[03] ---------------------------------------------------
[04] This batch file will disable the nominated network
[05] adapter, wait 10 seconds, then re-enable it.
[06] 20.7.2009 FNL
[07] ---------------------------------------------------
[08] :Start
[09] setlocal enabledelayedexpansion
[10] set Adapter=Intel(R) PRO/1000 PL Network Connection
[11] call :Sub disable
[12] ping localhost -n 9 nul
[13] call :Sub enable
[14] goto :eof
[15]
[16] :Sub
[17] set HWID=x
[18] set count=0
[19] set found=no
[20]
[21] c:\Tools\devcon hwids "PCI\*" "%temp%\device.txt"
[22] for /F "tokens=*" %%* in ('type "%temp%\device.txt"') do (
[23] set /a count=!count! + 1
[24] if /i "%%*"=="Name: %Adapter%" set found=yes& set count=1
[25] if !found!==yes if !count!==3 set HWID=%%*
[26] )
[27] if %found%==yes (
[28] c:\Tools\devcon %1 "!HWID!"
[29] ) else (
[30] echo Device "%Adapter%" not found.
[31] )
[32] del "%temp%\device.txt"


Thank you for that script, Pegasus. Looks like batch file syntax has
gotten a little more powerful since the DOS 6.22 days. I'd be
interested in studying some of those commands later. But I can tell
you that it works. I did take out lines 21 and 32, and replaced the
'type tempfile' command in line 22 with the command in line 21.

Also, I thought the call command was non-blocking, which is why you
need that ping command to simulate a sleep, but I just did some
experimenting with that. I put in an echo statement as the first line
of the subroutine, and then put in a ping for 10 seconds as the second
line of the subroutine. I figured I would see two immediate printouts
since the call command is supposed to be non-blocking, but I only saw
the second printout after the first call to the subroutine had
finished. Maybe this script is hitting some blocking aspect of the
call command?

Task Scheduler works fine (both the startup and logon options),
although I do see the cmd window with the logon option. I also had
success opening up gpedit.msc, and specifying the script as a startup
script and also as a logon script - and the cmd window does not appear
if I do it that way. Seems like whichever option I choose (whether
Task Scheduler or gpedit.msc, and whether startup or logon), I can
actually logon quickly enough and start doing stuff before the script
executes. That's ok, I guess it's the best we can do.

===============

Thanks for the feedback. I can't really comment on your observations you
made in the second paragraph unless you post the actual code you used.
Suffice it to say that it does not matter in the least whether you execute a
command in the main part of the batch file or in the subroutine. I used a
subroutine because it's bad programming practice to repeat code that is
functionally almost identical.


Ads