; NVIDIA Display Driver uninstaller
call Uninstall

[UninstallSilent]
Set ForceNoReboot=yes
call UninstallSilentReboot

[UninstallSilentReboot]
Set Silent=yes
call Uninstall
Delreg {UninstRegkey}\NVIDIA Display Driver

[Uninstall]
; echo Uninstall
enumregcmd HKLM\SYSTEM\CurrentControlSet\Control\Video\{*},call EnumVideoKeys
; echo InfPath : {InfPath}
CheckPath INFCHECK={windir}\Inf\{InfPath}
if {INFCHECK}=TRUE then call RunDpinst

; echo Old Version = {Version}
set OldVersion={Version}
enumregcmd HKLM\SYSTEM\CurrentControlSet\Control\Video\{*},call EnumVideoKeys
; echo New Version = {Version}
if {Version}={OldVersion} then call ManualRemove

call CleanUp

; Hack to trigger a reboot
Copy {current Script},{sysdir}\deleteme.txt
DelBoot {sysdir}\deleteme.txt

[ManualRemove]
RemoveDevice pci,VEN_10DE,Display

[RunDpinst]
SysCallAndWait {sysdir}\dpinst.exe /u {windir}\Inf\{InfPath} /s

[CleanUp]
; echo Cleaning stuff up

set NVIDIADriverFound=FALSE
enumregcmd HKLM\SYSTEM\CurrentControlSet\Control\Video\{*},call EnumVideoKeys
if {InBoxDriverFound}=TRUE then call LeaveInBox
if {NVIDIADriverFound}=FALSE then call DeleteAll

[EnumVideoKeys]
set MyBaseKey={Current Root Key}\{Current Reg Key}
enumregcmd {MyBaseKey}\{*},call CheckNVIDIAVideoKeys

[CheckNVIDIAVideoKeys]
set DriverDesc=FOOBAR
; echo Current Root Key : {Current Root Key}
; echo Current Reg Key : {Current Reg Key}
GetReg DriverDesc={Current Root Key}\{Current Reg Key}\DriverDesc
; echo DriverDesc: {DriverDesc}
if {DriverDesc}%NVIDIA then set NVIDIADriverFound=TRUE
if {DriverDesc}%NVIDIA then if {DriverDesc}%Microsoft then set InBoxDriverFound=TRUE
if {DriverDesc}%NVIDIA then GetReg InfPath={Current Root Key}\{Current Reg Key}\InfPath
if {DriverDesc}%NVIDIA then GetReg Version={Current Root Key}\{Current Reg Key}\DriverVersion
; echo Version: {Version}

[DeleteAll]
; echo No NVIDIA driver.  Deleting all NVIDIA files.
delboot {sysdir}\nvapi.dll
delboot {sysdir}\nvapi64.dll
delboot {sysdir}\nvd3dum.dll
delboot {sysdir}\nvd3dumx.dll
Delboot {sysdir}\drivers\nvlddmkm.sys
call LeaveInBox

DelReg HKLM\Software\NVIDIA Corporation\Global\NvCplApi
DelReg HKLM\Software\NVIDIA Corporation\Global\NVTweak
DelReg HKLM\Software\NVIDIA Corporation\Global\MediaCenterTray
DelRegE HKLM\Software\NVIDIA Corporation\Global
Delreg {UninstRegkey}\NVIDIA Display Driver
DelReg HKLM\Software\NVIDIA Corporation\NVAPI
DelReg HKLM\SYSTEM\{*ControlSet}\Services\nv\NVAPI
DelReg HKLM\SYSTEM\{*ControlSet}\Services\nvlddmkm\NVAPI
DelReg HKLM\SYSTEM\{*ControlSet}\Services\nvlddmkm


[LeaveInBox]
; echo NVIDIA Inbox driver found.  Leaving InBox Files

call UninstallSedona

UninstallService NVSvc

delboot {sysdir}\nvwgf2um.dll
delboot {sysdir}\nvwgf2umx.dll
Delboot {sysdir}\nvmctray.dll
Delboot {sysdir}\nvoglv32.dll
delboot {sysdir}\nvoglv64.dll
Delboot {sysdir}\nvsvc.dll
Delboot {sysdir}\nvsvc64.dll
Delboot {sysdir}\nvmccs.dll
Delboot {sysdir}\nvmccsrs.dll
Delboot {sysdir}\nvcolor.exe
Delboot {sysdir}\nvapps.xml
Delboot {sysdir}\nvwsapps.xml
Delboot {sysdir}\nvcod.dll
Delboot {sysdir}\nvcodins.dll
Delboot {sysdir}\nvuninst.exe
Delboot {Current Parser Path}

delreg HKLM\Software\Microsoft\Windows\CurrentVersion\Run\NvMediaCenter
delreg HKLM\Software\Microsoft\Windows\CurrentVersion\Run\NvCplDaemon
delreg HKLM\Software\Microsoft\Windows\CurrentVersion\Run\NvSvc



[UninstallSedona]
; echo Uninstalling Sedona
SysCallAndWait {sysdir}\regsvr32.exe /s /u {sysdir}\nvcpl.dll
SysCallAndWait {sysdir}\regsvr32.exe /s /u {sysdir}\nvmccs.dll
SysCallAndWait {sysdir}\regsvr32.exe /s /u {sysdir}\nvmccss.dll
SysCallAndWait {sysdir}\regsvr32.exe /s /u {sysdir}\nvdisps.dll
SysCallAndWait {sysdir}\regsvr32.exe /s /u {sysdir}\nvgames.dll
SysCallAndWait {sysdir}\regsvr32.exe /s /u {sysdir}\nvmobls.dll
SysCallAndWait {sysdir}\regsvr32.exe /s /u {sysdir}\nvvitvs.dll
SysCallAndWait {sysdir}\regsvr32.exe /s /u {sysdir}\nvwss.dll

Delboot {sysdir}\nvcpl.dll
Delboot {sysdir}\nvdisps.dll
Delboot {sysdir}\nvgames.dll
Delboot {sysdir}\nvmccss.dll
Delboot {sysdir}\nvmccs.dll
Delboot {sysdir}\nvmobls.dll
Delboot {sysdir}\nvvitvs.dll
Delboot {sysdir}\nvwss.dll

Set current file
DirAndApply {windir}\help\nvcpl\nvcpl*.cab,Delboot {current file}
Set current file
DirAndApply {windir}\help\nvcpl\nvdsp*.chm,Delboot {current file}
Set current file
DirAndApply {windir}\help\nvcpl\nv3d*.chm,Delboot {current file}
Set current file
DirAndApply {windir}\help\nvcpl\nvmob*.chm,Delboot {current file}
Set current file
DirAndApply {windir}\help\nvcpl\nvwks*.chm,Delboot {current file}

Set ServersPresent=0
EnumRegNamesCmd HKLM\Software\NVIDIA Corporation\NVControlPanel\RegisteredServers, set ServersPresent=1
EnumRegNamesCmd HKLM\Software\NVIDIA Corporation\Global\NVControlPanel\RegisteredServers, set ServersPresent=1
if {ServersPresent}=0 then call UninstallSedonaClient

[UninstallSedonaClient]
; echo Uninsatlling Sedona Client
Delboot {sysdir}\nvcpl.exe
Delboot {sysdir}\nvcplui.exe
Delboot {sysdir}\nvcpl.cpl
Delboot {sysdir}\nvcpluir.dll
Delboot {sysdir}\nvexpbar.dll
Delboot {sysdir}\nvdispsr.dll
Delboot {sysdir}\nvgamesr.dll
Delboot {sysdir}\nvmccssr.dll
Delboot {sysdir}\nvmoblsr.dll
Delboot {sysdir}\nvvitvsr.dll
Delboot {sysdir}\nvwssr.dll

Set current file
DirAndApply {windir}\help\nvcpl\nvcpl*.chm,Delboot {current file}
Del {windir}\help\nvcpl
DelReg HKLM\Software\NVIDIA Corporation\NVControlPanel
DelRegE HKLM\Software\NVIDIA Corporation
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel
DelRegE HKCU\Software\NVIDIA Corporation


