; Let's uninstall everything in reverse sequence that we installed

; Uninstall network management
getreg UninstallCommand={uninstregkey}\InstallShield_{8797FC40-AE6F-4AF3-9485-0A51668A46CE}\UninstallString
syscallandwait {UninstallCommand} /z/uninstall

; Uninstall function driver
call functiondriveruninst

; Uninstall bus driver
call busdriveruninst


[busdriverUninst]
Set Display Name=Nvidia Network Bus Enumerator 
; Remove any NVIDIA device driver if present
UninstallService nvnetbus
RemoveDevice pci,VEN_10DE&DEV_008C, any
RemoveDevice pci,VEN_10DE&DEV_00DF, any

; Now try to delete files used by Bus driver
DelOemInfs nv*,Version,CatalogFile,nvnetbus.cat,version,Provider,%NVDA%
DelIniIfMatched {windir}\inf\internet\NVidiaNetbus.inf,Version,CatalogFile,nvnetbus.cat,version,Provider,%NVDA%

DelBoot {sysdir}\nvnetbus.sys
DelBoot {sysdir}\nvnrm.sys
DelBoot {sysdir}\nvsnpu.sys

; Also delete them from {sysdir}\drivers folder
DelBoot {sysdir}\drivers\nvnetbus.sys
DelBoot {sysdir}\drivers\nvnrm.sys 
DelBoot {sysdir}\drivers\nvsnpu.sys

DelBoot {sysdir}\bdco1.dll
DelBoot {sysdir}\NVCONRM.DLL

; also delete its uninstaller binary
Del {sysdir}\nvunrm.exe
Del {sysdir}\nvcoe.dll

Delreg HKLM\SYSTEM\{*ControlSet}\Class\{1a3e09be-1e45-494b-9174-d7385b45bbf5}
Delreg HKLM\SYSTEM\{*ControlSet}\control\class\{1A3E09BE-1E45-494B-9174-D7385B45BBF5}

DelReg HKLM\SYSTEM\{*ControlSet}\Services\nvnetbus


[functiondriveruninst]
; Remove Ethernet Function driver if present
UninstallService NVENETFD
RemoveDevice NVNET,VEN_10DE&DEV_008C, any
RemoveDevice NVNET,VEN_10DE&DEV_00DF, any
RemoveDevice {1a3e09be-1e45-494b-9174-d7385b45bbf5},NVNET_, any

; Now try to delete files used by Ethernet Function driver
DelOemInfs nv*,Version,Class,net,version,Provider,%Nvidia%,Version,CatalogFile,NVENETFD.CAT
DelIniIfMatched {windir}\inf\internet\NVidianvenetfd.inf,Version,Class,net,version,Provider,%Nvidia%,Version,CatalogFile,NVENETFD.CAT

DelBoot {sysdir}\nvenetfd.sys
DelBoot {sysdir}\Drivers\nvenetfd.sys
DelBoot {sysdir}\fdco1.dll

EnumRegCmd HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\{*},call CheckProvider

DelReg HKLM\SYSTEM\{*ControlSet}\Services\nvenetfd
DelReg HKLM\SYSTEM\{*ControlSet}\Services\EventLog\System\nvenetfd

[CheckProvider]
GetReg Description={Current Root Key}\{Current Reg Key}\Description
if {Description}=NVIDIA nForce MCP2S Networking Adapter then DelReg {Current Root Key}\{Current Reg Key}
