; NVIDIA Display Driver uninstaller
killapp nvCplUI.exe
call Uninstall

[UninstallSilent]
Set ForceNoReboot=yes
call UninstallSilentReboot

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

[Uninstall]
; echo Uninstall
SysCallAndWait MsiExec /x{3D3E663D-4E7E-4577-A560-7ECDDD45548A} /quiet /norestart
SysCallAndWait MsiExec /x{275E55FA-1CB3-4B53-924B-3B43AA701FB6} /quiet /norestart
del {sysdir}\pvsonydll.dll
del {syswow64dir}\pvsonydll.dll
SysCallAndWait MsiExec /x{F4469132-EA9F-444A-BFFB-323C7413E951} /quiet /norestart
SysCallAndWait MsiExec /x{4C0A8D65-4286-4B58-87FE-18AD24289285} /quiet /norestart
SysCallAndWait MsiExec /x{71807498-D8E2-41C6-84CD-8ED7A076B6EC} /quiet /norestart
SysCallAndWait {syswow64dir}\nViewSetup -s -uninstall
RemoveDevice pci,VEN_10DE,Display

call CleanUp

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

[ManualRemove]
RemoveDevice pci,VEN_10DE,Display

[RunDpinst]
if {LeaveDriverStoreCache}=No then SysCallAndWait {sysdir}\dpinst.exe /u {windir}\Inf\{InfPath} /s

[CleanUp]
; echo Cleaning stuff up

; echo deleting the "Portal" game related items
del {windir}\nvidia icons\Portal_32x32.ico
del {windir}\nvidia icons\Portal_48x48.ico
GetFolderPath Desktop=25
del {Desktop}\Play Portal Now.lnk

; make sure the TMM persistence files are deleted on uninstall in all cases.
Del {pgmdir}\nvModes.dat
Del {pgmdir}\nvModes.001
Del {pgmdir}\nvUnsupRes.dat

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

set NVIDIADriverFound=FALSE
enumregcmd HKLM\SYSTEM\CurrentControlSet\Control\Video\{*},call EnumVideoKeysForDelete

[EnumVideoKeysForDelete]
set Found0000=FALSE
set Service
set MyBaseKey={Current Root Key}\{Current Reg Key}
enumregcmd {MyBaseKey}\{*},call CheckNVIDIAVideoKeys
if {Service}%nv then if {Found0000}=FALSE then DelReg {Current Root Key}\{Current Reg Key}

[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
if {DriverDesc}%NVIDIA then GetReg CoInstaller={Current Root Key}\{Current Reg Key}\Uninstall\CoInstaller
; echo Version: {Version}
GetReg Service={Current Root Key}\{Current Reg Key}\Service
if {Current Reg Key}%0000 then set Found0000=TRUE


[DeleteAll]
; echo No NVIDIA driver.  Deleting all NVIDIA files.
delbootquiet {sysdir}\nvapi.dll
delbootquiet {sysdir}\nvapi64.dll
del {sysdir}\nvd3dum.dll
del {sysdir}\nvd3dumx.dll
del {sysdir}\drivers\nvlddmkm.sys
del {sysdir}\drivers\nvbridge.kmd

delbootquiet {syswow64dir}\nvapi.dll
del {syswow64dir}\nvd3dum.dll
call LeaveInBox

DelReg HKCR\VirtualStore\MACHINE\SOFTWARE\NVIDIA Corporation\Global
DelRegE HKCR\VirtualStore\MACHINE\SOFTWARE\NVIDIA Corporation
DelReg HKLM\Software\NVIDIA Corporation\Global\NvCplApi
DelReg HKCU\Software\NVIDIA Corporation\Global\NvCplApi
DelReg HKLM\Software\NVIDIA Corporation\Global\NVTweak
DelReg HKCU\Software\NVIDIA Corporation\Global\NVTweak
DelReg HKLM\Software\NVIDIA Corporation\Global\MediaCenterTray
DelReg HKLM\Software\NVIDIA Corporation\Global\Hybrid\Action
DelReg HKLM\Software\NVIDIA Corporation\Global\Hybrid
DelReg HKLM\Software\NVIDIA Corporation\Global\NvSvc
DelRegE HKCU\Software\NVIDIA Corporation\Global
DelRegE HKLM\Software\NVIDIA Corporation\Global
DelReg HKLM\Software\NVIDIA Corporation\Installer
DelReg HKLM\Software\NVIDIA Corporation\nvDelFiles
DelRegE HKCU\Software\NVIDIA Corporation
DelRegE HKLM\Software\NVIDIA Corporation
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

del {sysdir}\nvwgf2um.dll
del {sysdir}\nvwgf2umx.dll
delbootquiet {sysdir}\nvmctray.dll
del {sysdir}\nvoglv32.dll
del {sysdir}\nvoglv64.dll
del {sysdir}\nvsvc.dll
del {sysdir}\nvsvcr.dll
del {sysdir}\nvsvc64.dll
del {sysdir}\nvmccs.dll
del {sysdir}\nvmccsrs.dll
del {sysdir}\nvvsvc.exe
del {sysdir}\nvcolor.exe
del {sysdir}\nvapps.xml
del {sysdir}\nvwsapps.xml
delbootquiet {sysdir}\nvcod.dll
delbootquiet {sysdir}\nvcodins.dll
delbootquiet {sysdir}\nvcodh.dll
delbootquiet {sysdir}\nvcodhins.dll
delbootquiet {sysdir}\nvudisp.exe
delbootquiet {sysdir}\{CoInstaller}
del {sysdir}\nvcuda.dll
del {sysdir}\nvcuvenc.dll
del {sysdir}\nvcuvid.dll
del {wrkdir}\nvapps.xml
del {wrkdir}\nvwsapps.xml
del {wrkdir}\NvStarted
del {wrkdir}\NvSetnative



del {syswow64dir}\nvwgf2um.dll
del {syswow64dir}\nvcuda.dll
del {syswow64dir}\nvcuvenc.dll
del {syswow64dir}\nvoglv32.dll
del {syswow64dir}\nvapps.xml
del {syswow64dir}\nvwsapps.xml
del {syswow64dir}\nvcuvid.dll

delreg HKLM\Software\Microsoft\Windows\CurrentVersion\Run\NvMediaCenter
delreg HKLM\Software\Microsoft\Windows\CurrentVersion\Run\NvCplDaemon
delreg HKLM\Software\Microsoft\Windows\CurrentVersion\Run\NvSvc
delreg HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain\RestoreProfile
delreg HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain\RestoreGlobals



[UninstallSedona]
; echo Uninstalling Sedona
SysCallAndWait {sysdir}\regsvr32.exe /s /u {sysdir}\nvshext.dll
SysCallAndWait {sysdir}\regsvr32.exe /s /u {sysdir}\nvcpl.dll
SysCallAndWait {sysdir}\regsvr32.exe /s /u {sysdir}\nvsvs.dll
SysCallAndWait {sysdir}\regsvr32.exe /s /u {sysdir}\nvsvsr.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
SysCallAndWait {sysdir}\regsvr32.exe /s /u {sysdir}\nvsvc.dll
SysCallAndWait {sysdir}\regsvr32.exe /s /u {sysdir}\nvsvc64.dll
SysCallAndWait {sysdir}\regsvr32.exe /s /u {sysdir}\nvvsvc.exe

delbootquiet {sysdir}\nvshext.dll
del {sysdir}\nvcpl.dll
del {sysdir}\nvdisps.dll
del {sysdir}\nvgames.dll
del {sysdir}\nvmccss.dll
del {sysdir}\nvmccs.dll
del {sysdir}\nvmobls.dll
del {sysdir}\nvvitvs.dll
del {sysdir}\nvwss.dll
del {sysdir}\nvhotkey.dll
del {sysdir}\oemdspif.dll
del {sysdir}\nvsvs.dll
del {sysdir}\nvsvsr.dll
del {sysdir}\NvPVEnc.ax

Set current file
DirAndApply {windir}\help\nvcpl\nvcpl*.cab,del {current file}
Set current file
DirAndApply {windir}\help\nvcpl\nvdsp*.chm,del {current file}
Set current file
DirAndApply {windir}\help\nvcpl\nv3d*.chm,del {current file}
Set current file
DirAndApply {windir}\help\nvcpl\nvmob*.chm,del {current file}
Set current file
DirAndApply {windir}\help\nvcpl\nvwks*.chm,del {current file}
Set current file
DirAndApply {wrkdir}\*.NVP,del {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
del {sysdir}\nvcpl.exe
del {sysdir}\nvcplui.exe
del {sysdir}\nvcpl.cpl
del {sysdir}\nvcpluir.dll
del {sysdir}\nvexpbar.dll
del {sysdir}\nvdispsr.dll
del {sysdir}\nvgamesr.dll
del {sysdir}\nvmccssr.dll
del {sysdir}\nvmoblsr.dll
del {sysdir}\nvvitvsr.dll
del {sysdir}\nvwssr.dll

Set current file
DirAndApply {windir}\help\nvcpl\nvcpl*.chm,del {current file}
Del {windir}\help\nvcpl
DelReg HKLM\Software\NVIDIA Corporation\NVControlPanel
DelReg HKCU\Software\NVIDIA Corporation\NVIDIA Control Panel
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel
DelReg HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\NVHotkey


set Shortcutpath={CommonPrograms}\NVIDIA Corporation\NVIDIA Control Panel
set ShortcutName=Control Panel.lnk
call DelShortCut
del {CommonPrograms}\NVIDIA Corporation

[DelShortCut]
del {Shortcutpath}\{ShortcutName}
del {Shortcutpath}
