; NVIDIA Display Driver uninstaller
call Uninstall

[UninstallSilent]
Set ForceNoReboot=yes
Set Silent=yes
call Uninstall

[Uninstall]
UninstallService NVSvc
SysCallAndWait {sysdir}\nwiz.exe /uninstall
; remove nView dir if empty
Del {windir}\nView 

call Clean up registry

; Get rid of the non-workstation NV specific stuff in the local area
set RootKey=HKCU
call DelNoneWorkStationKeys

Call DeleteFiles

RemoveDevice pci,VEN_10DE,Display

DelReg HKLM\Software\Microsoft\Windows\CurrentVersion\Run\NvDeskMgrRestart

; also delete its uninstaller binary
DelBoot {sysdir}\nvudisp.exe

[Clean up registry]
call RemoveInfFromRegistry
DelReg HKLM\Software\Microsoft\Windows NT\CurrentVersion\OpenGLDrivers\RIVATNT
DelReg HKLM\Software\Microsoft\Windows\CurrentVersion\Run\NvCplDaemon
DelReg HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce\NvCplDaemon
Delreg HKLM\Software\Microsoft\Windows\CurrentVersion\Run\nwiz
Delreg HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce\nwiz

DelReg HKLM\HARDWARE\\RESOURCEMAP\\VIDEO\nv4
DelReg HKLM\HARDWARE\\RESOURCEMAP\\VIDEO\nv

set RootKey=HKLM\SYSTEM\{*ControlSet}
call EnumAndDeleteHWKeys

; NvTweak
DelReg HKCR\CLSID\{FFB699E0-306A-11d3-8BD1-00104B6F7516}
set RootKey=HKLM
call DeleteNTTweak
set RootKey=HKCU
call DeleteNTTweak

[DelNoneWorkStationKeys]
set BaseKey={RootKey}\SOFTWARE\NVIDIA Corporation\Global
DelReg  {BaseKey}\NvSvc
DelReg  {BaseKey}\NVTweak
DelReg  {BaseKey}\NVDesk
DelReg  {BaseKey}\Setup
DelReg  {BaseKey}\MediaCenterTray
set BaseKey={RootKey}\SOFTWARE\NVIDIA Corporation
DelReg  {BaseKey}\Global
DelRegE {BaseKey}


[EnumAndDelProfileKeys]
DelReg {RegPath}\{*}\System\CurrentControlSet\Services\nv4
DelReg {RegPath}\{*}\System\CurrentControlSet\Services\nv

[EnumAndDeleteHWKeys]
DelReg {RootKey}\Services\nv4
DelReg {RootKey}\Services\EventLog\System\nv4
DelReg {RootKey}\Enum\Root\LEGACY_NV4
DelReg {RootKey}\Services\nv
DelReg {RootKey}\Services\EventLog\System\nv
DelReg {RootKey}\Enum\Root\LEGACY_NV
set RegPath={RootKey}\Services
DelReg {RegPath}\nvcap
DelReg {RegPath}\nvtunep
DelReg {RegPath}\tvsnd
DelReg {RegPath}\nvxbar
set RegPath={RootKey}\Enum\DISPLAY
DelReg {RegPath}\nvcap
DelReg {RegPath}\nvtunep
DelReg {RegPath}\tvsnd
DelReg {RegPath}\nvxbar
DelReg {RegPath}\nvMultiView
set RegPath={RootKey}\Hardware Profiles
call EnumAndDelProfileKeys
EnumRegCmd {RootKey}\Control\Class\{4D36E968-E325-11CE-BFC1-08002BE10318}\{*0},Call CheckProvider

[CheckProvider]
GetReg Provider={Current Root Key}\{Current Reg Key}\ProviderName
if {Provider}=NVIDIA then DelReg {Current Root Key}\{Current Reg Key}

[CheckDriver]
GetReg Class={Current Root Key}\{Current Reg Key}\class
GetReg Mfg={Current Root Key}\{Current Reg Key}\Mfg
if {Class},{Mfg}=Display,NVIDIA then DelReg {Current Root Key}\{Current Reg Key}

[DeleteNTTweak]
set Regkey={RootKey}\Software\Microsoft\Windows\CurrentVersion
DelReg {Regkey}\Controls Folder\Display\shellex\PropertySheetHandlers\NVIDIA CPL Extension
DelReg {Regkey}\Run\Nv4QuickTweak
DelReg {Regkey}\Run\Nv4ColorInit
DelReg {Regkey}\Run\NvInitialize
DelReg {Regkey}\Run\NvMediaCenter
DelReg {Regkey}\Run\NvDeskMgrRestart

[DeleteFiles]
; delete oem*.inf files that have the following information
; wildcard for filename, section1,variable1,value1 [,section2,variable2,value2[,...]]  
DelOemInfs nv*,Version,Class,Display,Version,Provider,%NVIDIA%
DelOemInfs nv*,Version,Class,Display,Strings,Mfg,NVIDIA
DelIniIfMatched {windir}\INF\INTERNET\NVIDIA*.INF,Version,Class,Display

set BasePath={sysdir}
DelBoot {basepath}\nv4_disp.dll
DelBoot {basepath}\nvdccapp.cfg
DelBoot {basepath}\nvwsapps.cfg
DelBoot {basepath}\nvtuicpl.cpl
DelBoot {basepath}\nvcpl.dll
DelBoot {basepath}\nview.dll
DelBoot {basepath}\nviewimg.dll
DelBoot {basepath}\nviewx.dll
DelBoot {basepath}\nvinstnt.dll
DelBoot {basepath}\nvmctray.dll
DelBoot {basepath}\nvnt4cpl.dll
DelBoot {basepath}\nvoglnt.dll
DelBoot {basepath}\nvshell.dll
DelBoot {basepath}\nvwddi.dll
DelBoot {basepath}\nvwdmcpl.dll
DelBoot {basepath}\dmcpl.exe
DelBoot {basepath}\keystone.exe
DelBoot {basepath}\nvappbar.exe
DelBoot {basepath}\nvsvc.exe
DelBoot {basepath}\nvsvc32.exe
DelBoot {basepath}\nwiz.exe
DelBoot {basepath}\aliagp.sys
DelBoot {basepath}\drivers\nv4_mini.sys
DelBoot {basepath}\nvcod.dll

DelBoot {basepath}\nvarch16.dll
DelBoot {basepath}\nvarch32.dll
DelBoot {basepath}\nvdd32.dll
DelBoot {basepath}\nvmode.dll
DelBoot {basepath}\nvopengl.dll
DelBoot {basepath}\nvdisp.drv
DelBoot {basepath}\agart.vxd
DelBoot {basepath}\nvcore.vxd
DelBoot {basepath}\nvmini.vxd
DelBoot {basepath}\nvmini2.vxd
DelBoot {basepath}\alipcimp.pci
DelBoot {basepath}\nvinst32.dll

DelBoot {sysdir}\dllcache\nv4_mini.sys
DelBoot {sysdir}\dllcache\nv4_disp.dll
DelBoot {windir}\SysWOW64\nvogl32.dll

; Resource DLLs
DelBoot {basepath}\nvrsar.dll
DelBoot {basepath}\nvrscs.dll
DelBoot {basepath}\nvrsda.dll
DelBoot {basepath}\nvrsde.dll
DelBoot {basepath}\nvrsel.dll
DelBoot {basepath}\nvrseng.dll
DelBoot {basepath}\nvrses.dll
DelBoot {basepath}\nvrsesm.dll
DelBoot {basepath}\nvrsfi.dll
DelBoot {basepath}\nvrsfr.dll
DelBoot {basepath}\nvrshe.dll
DelBoot {basepath}\nvrshu.dll
DelBoot {basepath}\nvrsit.dll
DelBoot {basepath}\nvrsja.dll
DelBoot {basepath}\nvrsko.dll
DelBoot {basepath}\nvrsnl.dll
DelBoot {basepath}\nvrsno.dll
DelBoot {basepath}\nvrspl.dll
DelBoot {basepath}\nvrspt.dll
DelBoot {basepath}\nvrsptb.dll
DelBoot {basepath}\nvrsru.dll
DelBoot {basepath}\nvrssk.dll
DelBoot {basepath}\nvrssl.dll
DelBoot {basepath}\nvrssv.dll
DelBoot {basepath}\nvrstr.dll
DelBoot {basepath}\nvrszhc.dll
DelBoot {basepath}\nvrszht.dll

; nView Resource DLLs
DelBoot {basepath}\nvwrsar.dll
DelBoot {basepath}\nvwrscs.dll
DelBoot {basepath}\nvwrsda.dll
DelBoot {basepath}\nvwrsde.dll
DelBoot {basepath}\nvwrsel.dll
DelBoot {basepath}\nvwrseng.dll
DelBoot {basepath}\nvwrses.dll
DelBoot {basepath}\nvwrsesm.dll
DelBoot {basepath}\nvwrsfi.dll
DelBoot {basepath}\nvwrsfr.dll
DelBoot {basepath}\nvwrshe.dll
DelBoot {basepath}\nvwrshu.dll
DelBoot {basepath}\nvwrsit.dll
DelBoot {basepath}\nvwrsja.dll
DelBoot {basepath}\nvwrsko.dll
DelBoot {basepath}\nvwrsnl.dll
DelBoot {basepath}\nvwrsno.dll
DelBoot {basepath}\nvwrspl.dll
DelBoot {basepath}\nvwrspt.dll
DelBoot {basepath}\nvwrsptb.dll
DelBoot {basepath}\nvwrsru.dll
DelBoot {basepath}\nvwrssk.dll
DelBoot {basepath}\nvwrssl.dll
DelBoot {basepath}\nvwrssv.dll
DelBoot {basepath}\nvwrstr.dll
DelBoot {basepath}\nvwrszhc.dll
DelBoot {basepath}\nvwrszht.dll

; Help Files
set BasePath={windir}\help
DelBoot {basepath}\nv3tweak.hlp
DelBoot {basepath}\nvcpar.hlp
DelBoot {basepath}\nvcpcs.hlp
DelBoot {basepath}\nvcpda.hlp
DelBoot {basepath}\nvcpde.hlp
DelBoot {basepath}\nvcpel.hlp
DelBoot {basepath}\nvcpeng.hlp
DelBoot {basepath}\nvcpes.hlp
DelBoot {basepath}\nvcpesm.hlp
DelBoot {basepath}\nvcpfi.hlp
DelBoot {basepath}\nvcpfr.hlp
DelBoot {basepath}\nvcpfr.hlp
DelBoot {basepath}\nvcphe.hlp
DelBoot {basepath}\nvcphu.hlp
DelBoot {basepath}\nvcpit.hlp
DelBoot {basepath}\nvcpja.hlp
DelBoot {basepath}\nvcpko.hlp
DelBoot {basepath}\nvcpl.hlp
DelBoot {basepath}\nvcpnl.hlp
DelBoot {basepath}\nvcpno.hlp
DelBoot {basepath}\nvcppl.hlp
DelBoot {basepath}\nvcppt.hlp
DelBoot {basepath}\nvcpptb.hlp
DelBoot {basepath}\nvcpru.hlp
DelBoot {basepath}\nvcpsk.hlp
DelBoot {basepath}\nvcpsl.hlp
DelBoot {basepath}\nvcpsv.hlp
DelBoot {basepath}\nvcpth.hlp
DelBoot {basepath}\nvcptr.hlp
DelBoot {basepath}\nvcpzhc.hlp
DelBoot {basepath}\nvcpzht.hlp

; nView Help Files
DelBoot {basepath}\nvwcpar.hlp
DelBoot {basepath}\nvwcpcs.hlp
DelBoot {basepath}\nvwcpda.hlp
DelBoot {basepath}\nvwcpde.hlp
DelBoot {basepath}\nvwcpel.hlp
DelBoot {basepath}\nvwcpeng.hlp
DelBoot {basepath}\nvwcpes.hlp
DelBoot {basepath}\nvwcpesm.hlp
DelBoot {basepath}\nvwcpfi.hlp
DelBoot {basepath}\nvwcpfr.hlp
DelBoot {basepath}\nvwcpfr.hlp
DelBoot {basepath}\nvwcphe.hlp
DelBoot {basepath}\nvwcphu.hlp
DelBoot {basepath}\nvwcpit.hlp
DelBoot {basepath}\nvwcpja.hlp
DelBoot {basepath}\nvwcpko.hlp
DelBoot {basepath}\nvwcplen.hlp
DelBoot {basepath}\nvwcpnl.hlp
DelBoot {basepath}\nvwcpno.hlp
DelBoot {basepath}\nvwcppl.hlp
DelBoot {basepath}\nvwcppt.hlp
DelBoot {basepath}\nvwcpptb.hlp
DelBoot {basepath}\nvwcpru.hlp
DelBoot {basepath}\nvwcpsk.hlp
DelBoot {basepath}\nvwcpsl.hlp
DelBoot {basepath}\nvwcpsv.hlp
DelBoot {basepath}\nvwcpth.hlp
DelBoot {basepath}\nvwcptr.hlp
DelBoot {basepath}\nvwcpzhc.hlp
DelBoot {basepath}\nvwcpzht.hlp

; Other files
DelBoot {basepath}\nvmontrs.cfg
DelBoot {basepath}\nv3api.dll
DelBoot {basepath}\nv3dd32.dll
DelBoot {basepath}\nv3ogl.dll
DelBoot {basepath}\nv3qtwk.dll
DelBoot {basepath}\nv3rm.vxd
DelBoot {basepath}\nv3sys.dll
DelBoot {basepath}\nv3tweak.dll
DelBoot {basepath}\nv4_kdisp.dll 
DelBoot {basepath}\nvdesk32.dll
DelBoot {basepath}\nvdmcpl.dll
DelBoot {basepath}\nvds15.dll
DelBoot {basepath}\nvdspmgr.dll
DelBoot {basepath}\nvgfx.dll
DelBoot {basepath}\nvogl32.dll
DelBoot {basepath}\nvqtwk.dll
DelBoot {basepath}\nvstercp.dll
DelBoot {basepath}\nvstercp.dll
DelBoot {basepath}\nvstres.dll
DelBoot {basepath}\maxtreme.drv
DelBoot {basepath}\nv3disp.drv
DelBoot {basepath}\nvfsvm.exe
DelBoot {basepath}\nvsttest.exe
DelBoot {basepath}\nvstview.exe
DelBoot {basepath}\quadroview.exe
DelBoot {basepath}\nvdual.sys
DelBoot {basepath}\nv3.vxd
DelBoot {basepath}\nv3mini2.vxd

;for older stuff we just delete them right away
Del {sysdir}\nvsys\nvinst32.dll 
Del {sysdir}\nvsys

[RemoveInfFromRegistry]
DelReg HKLM\Software\Microsoft\Windows\CurrentVersion\Setup\SetupX\INF\OEM Name\{windir}\INF\nvaml.inf
