Batch script to delete network driver
Moderator: DosItHelp
-
- Posts: 11
- Joined: 08 Aug 2016 09:40
Batch script to delete network driver
Hey,
i want a batch script that deletes this: driver and than shuts down the computer.
How can someone achieve that?
Thanks.
i want a batch script that deletes this: driver and than shuts down the computer.
How can someone achieve that?
Thanks.
Re: Batch script to delete network driver
I don't know where you made this screen shot. Displayed names may differ from names that command tools return.
Run the following line in a cmd.exe window and tell us what output you get:
Regards
aGerman
Run the following line in a cmd.exe window and tell us what output you get:
Code: Select all
wmic sysdriver where "displayname like 'VIA Rhine%'" get displayname
Regards
aGerman
-
- Posts: 11
- Joined: 08 Aug 2016 09:40
Re: Batch script to delete network driver
This is the result if I run this code.
-
- Posts: 11
- Joined: 08 Aug 2016 09:40
Re: Batch script to delete network driver
I want to imitate deleting the driver from the device manager like this:
If I do this:
it doesn't really help, I want Windows to reinstall the driver when I boot the PC, so, I mean, completely uninstall it.
I'm really new to this thing.
If I do this:
it doesn't really help, I want Windows to reinstall the driver when I boot the PC, so, I mean, completely uninstall it.
I'm really new to this thing.
Re: Batch script to delete network driver
kennedydid911 wrote:
This is the result if I run this code.
Did you know that you can copy and paste from the cmd Window and then just edit the text you want to obfuscate. Alot easier then editing an image file and then uploading it to a file sharing site.
Code: Select all
C:\Users\Squashman>wmic sysdriver where "displayname like 'Intel%'" get displayname
DisplayName
Intel AGP Bus Filter
Re: Batch script to delete network driver
Microsoft has a command-line tool to perform tasks like those done in device manager
It's called devcon.exe
It's called devcon.exe
-
- Posts: 11
- Joined: 08 Aug 2016 09:40
Re: Batch script to delete network driver
I want to run that batch script whenever my PC shuts down, is this possible with that devcon.exe?
Re: Batch script to delete network driver
kennedydid911 wrote:I want to run that batch script whenever my PC shuts down, is this possible with that devcon.exe?
Devcon doesn't change when a batch script runs.
Re: Batch script to delete network driver
That's not a matter of devcon. Do you want to automatically trigger a batch script that deletes the network adapter when you shut down your PC? Or would you rather run a script manually that deletes the network adapter and afterwards shuts down you PC?
Regards
aGerman
Regards
aGerman
-
- Posts: 11
- Joined: 08 Aug 2016 09:40
Re: Batch script to delete network driver
That automatic triggering method would be ideal, but if the only solution is a batch file on my desktop to shut down my PC, I would be happy with that too.
Re: Batch script to delete network driver
OK a fast script could probably run in the time between triggering the shutdown and the shutdown itself. Without any warranty ...
I assume you already downloaded devcon.exe.
- Create folder "C:\scripts"
- Copy devcon.exe into this folder.
- Save this code into this folder as "at_shutdown.bat" :
(Do not change any of these folder/file names!)
Now create a scheduled task that will run the batch file in the SYSTEM account (elevated, you don't even see the window flashing up) if the shutdown was triggered (Event ID 1074). If you don't know how to do that you can run the following code via right click -> "Run as Administrator".
Regards
aGerman
I assume you already downloaded devcon.exe.
- Create folder "C:\scripts"
- Copy devcon.exe into this folder.
- Save this code into this folder as "at_shutdown.bat" :
Code: Select all
@echo off &setlocal
cd /d "%~dp0"
for /f "delims=:" %%i in ('devcon.exe listclass net^|find "VIA Rhine"') do for /f %%j in ("%%i") do devcon.exe remove "%%j"
(Do not change any of these folder/file names!)
Now create a scheduled task that will run the batch file in the SYSTEM account (elevated, you don't even see the window flashing up) if the shutdown was triggered (Event ID 1074). If you don't know how to do that you can run the following code via right click -> "Run as Administrator".
Code: Select all
@echo off &setlocal
cd /d "%~dp0"
for /f "tokens=2 delims=:" %%i in ('chcp') do set /a oemcp=%%~ni
>nul chcp 1252
set "taskname=run_at_shutdown"
set "xmlfile=run_at_shutdown.xml"
set "line_01=<?xml version="1.0" encoding="UTF-16"?>"
set "line_02=<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">"
set "line_03= <RegistrationInfo>"
set "line_04= <Author>aGerman @ DosTips</Author>"
set "line_05= <URI>\run_at_shutdown</URI>"
set "line_06= <Description>Run Script At Shutdown</Description>"
set "line_07= </RegistrationInfo>"
set "line_08= <Triggers>"
set "line_09= <EventTrigger>"
set "line_10= <Enabled>true</Enabled>"
set "line_11= <Subscription><QueryList><Query Id="0" Path="System"><Select Path="System">*[System[Provider[@Name='User32'] and EventID=1074]]</Select></Query></QueryList></Subscription>"
set "line_12= </EventTrigger>"
set "line_13= </Triggers>"
set "line_14= <Principals>"
set "line_15= <Principal id="Author">"
set "line_16= <UserId>S-1-5-18</UserId>"
set "line_17= <RunLevel>HighestAvailable</RunLevel>"
set "line_18= </Principal>"
set "line_19= </Principals>"
set "line_20= <Settings>"
set "line_21= <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>"
set "line_22= <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>"
set "line_23= <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>"
set "line_24= <AllowHardTerminate>false</AllowHardTerminate>"
set "line_25= <StartWhenAvailable>false</StartWhenAvailable>"
set "line_26= <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>"
set "line_27= <IdleSettings>"
set "line_28= <StopOnIdleEnd>false</StopOnIdleEnd>"
set "line_29= <RestartOnIdle>false</RestartOnIdle>"
set "line_30= </IdleSettings>"
set "line_31= <AllowStartOnDemand>true</AllowStartOnDemand>"
set "line_32= <Enabled>true</Enabled>"
set "line_33= <Hidden>false</Hidden>"
set "line_34= <RunOnlyIfIdle>false</RunOnlyIfIdle>"
set "line_35= <WakeToRun>false</WakeToRun>"
set "line_36= <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>"
set "line_37= <Priority>5</Priority>"
set "line_38= </Settings>"
set "line_39= <Actions Context="Author">"
set "line_40= <Exec>"
set "line_41= <Command>C:\Windows\System32\cmd.exe</Command>"
set "line_42= <Arguments>/c "C:\scripts\at_shutdown.bat"</Arguments>"
set "line_43= </Exec>"
set "line_44= </Actions>"
set "line_45=</Task>"
<nul >"%xmlfile%" set /p "=ÿþ"
>>"%xmlfile%" cmd /u /q /c "for /f "tokens=1* delims==" %%i in ('set line_') do echo %%j"
>nul chcp %oemcp%
schtasks /create /xml "%xmlfile%" /tn "%taskname%" /f
del "%xmlfile%"
pause
Regards
aGerman
-
- Posts: 11
- Joined: 08 Aug 2016 09:40
Re: Batch script to delete network driver
If I create a scheduled task before shutting down the PC the script does not delete the driver.
So I tried just running the at_shutdown.bat, and I get this message: No devices removed.
What should I do next?
So I tried just running the at_shutdown.bat, and I get this message: No devices removed.
What should I do next?
Re: Batch script to delete network driver
Code: Select all
@echo off &setlocal
cd /d "%~dp0"
devcon listclass net
pause
Run that script in "C:\scripts" as administrator and please post the line of interest.
Regards
aGerman
-
- Posts: 11
- Joined: 08 Aug 2016 09:40
Re: Batch script to delete network driver
Code: Select all
Listing 10 device(s) for setup class "Net" (Network adapters).
ROOT\MS_AGILEVPNMINIPORT\0000 : WAN Miniport (IKEv
2)
ROOT\MS_L2TPMINIPORT\0000 : WAN Miniport (L2TP
)
ROOT\MS_NDISWANBH\0000 : WAN Miniport (Netw
ork Monitor)
ROOT\MS_NDISWANIP\0000 : WAN Miniport (IP)
ROOT\MS_NDISWANIPV6\0000 : WAN Miniport (IPv6
)
ROOT\MS_PPPOEMINIPORT\0000 : WAN Miniport (PPPO
E)
ROOT\MS_PPTPMINIPORT\0000 : WAN Miniport (PPTP
)
ROOT\MS_SSTPMINIPORT\0000 : WAN Miniport (SSTP
)
PCI\VEN_1106&DEV_3106&SUBSYS_747C1462&REV_8B\4&1F7DBC9F&0&48F0: VIA Rhine III Fa
st Ethernet Adapter
ROOT\*ISATAP\0000 : Microsoft ISATAP A
dapter
Press any key to continue . . .
Re: Batch script to delete network driver
Hmm. Looks correct Maybe the device has to be disabled beforehand.
You may run another test with a little more verbose output.
Regards
aGerman
You may run another test with a little more verbose output.
Code: Select all
@echo off &setlocal
cd /d "%~dp0"
devcon listclass net|find "VIA Rhine"
ECHO(
for /f "delims=:" %%i in ('devcon listclass net^|find "VIA Rhine"') do for /f %%j in ("%%i") do (
ECHO devcon disable "%%j"
devcon disable "%%j"
ECHO devcon remove "%%j"
devcon remove "%%j"
)
pause
Regards
aGerman