; NVIDIA Display Driver uninstaller
call Uninstall

[UninstallSilent]
Set ForceNoReboot=yes
call UninstallSilentReboot

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

[Uninstall]
set DelCmd=delbootquiet
if {LeaveDriverStoreCache}=No then set DelCmd=del
killapp nvCplUI.exe
StopService NVSvc, 129
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
;need to support uninstall nview in old and new location
SysCallAndWait {syswow64dir}\nViewSetup -s -uninstall
SysCallAndWait {programfilesdir}\NVIDIA Corporation\nview\nViewSetup -s -uninstall
enumregcmd HKLM\SYSTEM\CurrentControlSet\Control\Video\{*},call EnumVideoKeys
RemoveDevice pci,VEN_10DE,Display

call CleanUp
if {LeaveDriverStoreCache}=No then call HackReboot

[HackReboot]
; 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]
del {windir}\nvidia icons\Portal_32x32.ico
del {windir}\nvidia icons\Portal_48x48.ico
GetFolderPath Desktop=25
del {Desktop}\Play Portal Now.lnk
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
GetReg DriverDesc={Current Root Key}\{Current Reg Key}\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
GetReg Service={Current Root Key}\{Current Reg Key}\Service
if {Current Reg Key}%0000 then set Found0000=TRUE


[DeleteAll]
{DelCmd} {sysdir}\nvapi.dll
{DelCmd} {sysdir}\nvapi64.dll
{DelCmd} {sysdir}\nvd3dum.dll
{DelCmd} {sysdir}\nvdecodemft.dll
{DelCmd} {sysdir}\nvencodemft.dll
del {sysdir}\nvd3dumx.dll
del {sysdir}\drivers\nvlddmkm.sys
del {sysdir}\drivers\nvbridge.kmd

{DelCmd} {syswow64dir}\nvapi.dll
{DelCmd} {syswow64dir}\nvd3dum.dll
call LeaveInBox

DelReg HKCR\VirtualStore\MACHINE\SOFTWARE\NVIDIA Corporation\Global
DelRegE HKCR\VirtualStore\MACHINE\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]
call UninstallSysdirSedona
call UninstallPFSedona
if {NVCPLRSServersPresent}=0 then if {NVCPLRS2ServersPresent}=0 then if {NVCPL2RSServersPresent}=0 then call UninstallSedonaHelp

UninstallService NVSvc

del {sysdir}\nvwgf2um.dll
{DelCmd} {sysdir}\nvwgf2umx.dll
{DelCmd} {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
del {sysdir}\nvcoproc.bin
{DelCmd} {sysdir}\nvcod.dll
{DelCmd} {sysdir}\nvcodins.dll
{DelCmd} {sysdir}\nvcodh.dll
{DelCmd} {sysdir}\nvcodhins.dll
{DelCmd} {sysdir}\nvudisp.exe
{DelCmd} {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
{DelCmd} {sysdir}\nvcompiler.dll
{DelCmd} {sysdir}\opencl.dll

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
del {syswow64dir}\nvcuda.dll
Del {syswow64dir}\nvcuvenc.dll
{DelCmd} {syswow64dir}\nvcompiler.dll
{DelCmd} {syswow64dir}\opencl.dll

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
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 HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\NVHotkey
delreg HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain\RestoreProfile
delreg HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain\RestoreGlobals
DelReg HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\NVIDIA Display Control Panel
DelRegE HKCU\Software\NVIDIA Corporation
DelRegE HKLM\Software\NVIDIA Corporation

[UninstallSedonaHelp]
Set current file
DirAndApply {windir}\help\nvcpl\nvcpl*.cab,del {current file}
Set current file
DirAndApply {windir}\help\nvcpl\nvcpl*.chm,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
del {windir}\help\nvcpl

[UninstallSysdirSedona]
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

{DelCmd} {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
del {sysdir}\nvdispsr.dll
del {sysdir}\nvgamesr.dll
del {sysdir}\nvmccssr.dll
del {sysdir}\nvmoblsr.dll
del {sysdir}\nvvitvsr.dll
del {sysdir}\nvwssr.dll
del {sysdir}\easyUpdatusAPIU.dll
del {sysdir}\easyUpdatusAPIU64.dll

DirAndApply {wrkdir}\*.NVP,del {current file}

Set NVCPLRSServersPresent=0
EnumRegNamesCmd HKLM\Software\NVIDIA Corporation\NVControlPanel\RegisteredServers, increment NVCPLRSServersPresent
EnumRegNamesCmd HKLM\Software\NVIDIA Corporation\Global\NVControlPanel\RegisteredServers, increment NVCPLRSServersPresent
if {NVCPLRSServersPresent}=0 then call UninstallSysdirSedonaClient

[UninstallPFSedona]
SysCallAndWait {sysdir}\regsvr32.exe /s /u "{ProgramFilesDir}\NVIDIA Corporation\Display\nvsvs.dll"
SysCallAndWait {sysdir}\regsvr32.exe /s /u "{ProgramFilesDir}\NVIDIA Corporation\Display\nvsvsr.dll"
SysCallAndWait {sysdir}\regsvr32.exe /s /u "{ProgramFilesDir}\NVIDIA Corporation\Display\nvmccs.dll"
SysCallAndWait {sysdir}\regsvr32.exe /s /u "{ProgramFilesDir}\NVIDIA Corporation\Display\nvmccss.dll"
SysCallAndWait {sysdir}\regsvr32.exe /s /u "{ProgramFilesDir}\NVIDIA Corporation\Display\nvdisps.dll"
SysCallAndWait {sysdir}\regsvr32.exe /s /u "{ProgramFilesDir}\NVIDIA Corporation\Display\nvgames.dll"
SysCallAndWait {sysdir}\regsvr32.exe /s /u "{ProgramFilesDir}\NVIDIA Corporation\Display\nvmobls.dll"
SysCallAndWait {sysdir}\regsvr32.exe /s /u "{ProgramFilesDir}\NVIDIA Corporation\Display\nvvitvs.dll"
SysCallAndWait {sysdir}\regsvr32.exe /s /u "{ProgramFilesDir}\NVIDIA Corporation\Display\nvwss.dll"

SysCallAndWait "{ProgramFilesDir}\NVIDIA Corporation\Drs\dbInstaller.exe" -uninstall

del {ProgramFilesDir}\NVIDIA Corporation\Drs\dbInstaller.exe
del {ProgramFilesDir}\NVIDIA Corporation\Drs\nvdrsdb.bin
del {ProgramFilesDir}\NVIDIA Corporation\Drs

del {ProgramFilesDir}\NVIDIA Corporation\Display\nvdisps.dll
del {ProgramFilesDir}\NVIDIA Corporation\Display\nvgames.dll
del {ProgramFilesDir}\NVIDIA Corporation\Display\nvmccss.dll
del {ProgramFilesDir}\NVIDIA Corporation\Display\nvmccs.dll
del {ProgramFilesDir}\NVIDIA Corporation\Display\nvmobls.dll
del {ProgramFilesDir}\NVIDIA Corporation\Display\nvvitvs.dll
del {ProgramFilesDir}\NVIDIA Corporation\Display\nvwss.dll
del {ProgramFilesDir}\NVIDIA Corporation\Display\nvsvs.dll
del {ProgramFilesDir}\NVIDIA Corporation\Display\nvsvsr.dll
del {ProgramFilesDir}\NVIDIA Corporation\Display\nvdispsr.dll
del {ProgramFilesDir}\NVIDIA Corporation\Display\nvgamesr.dll
del {ProgramFilesDir}\NVIDIA Corporation\Display\nvmccssr.dll
del {ProgramFilesDir}\NVIDIA Corporation\Display\nvmoblsr.dll
del {ProgramFilesDir}\NVIDIA Corporation\Display\nvvitvsr.dll
del {ProgramFilesDir}\NVIDIA Corporation\Display\nvwssr.dll
del {ProgramFilesDir}\NVIDIA Corporation\Display
del {ProgramFilesDir}\NVIDIA Corporation

Set NVCPL2RSServersPresent=0
EnumRegNamesCmd HKLM\Software\NVIDIA Corporation\NVControlPanel2\RegisteredServers, increment NVCPL2RSServersPresent

Set NVCPLRS2ServersPresent=0
EnumRegNamesCmd HKLM\Software\NVIDIA Corporation\NVControlPanel\RegisteredServers2, increment NVCPLRS2ServersPresent

if {NVCPLRS2ServersPresent}=1 then if {NVCPL2RSServersPresent}=0 then call CheckCPL2RSDummyServerGUID

if {NVCPLRS2ServersPresent}=0 then if {NVCPL2RSServersPresent}=0 then call UninstallPFSedonaClient

[CheckCPL2RSDummyServerGUID]
set DummyExists=NULL
GetReg DummyExists=HKLM\Software\NVIDIA Corporation\NVControlPanel\RegisteredServers2\Dummy
if {DummyExists}={00000000-0000-0000-0000-000000000001} then set NVCPLRS2ServersPresent = 0


[UninstallSysdirSedonaClient]
del {sysdir}\nvcpl.exe
del {sysdir}\nvcplui.exe
del {sysdir}\nvcpl.cpl
del {sysdir}\nvcpluir.dll
del {sysdir}\nvexpbar.dll

DelReg HKLM\Software\NVIDIA Corporation\NVIDIA Control Panel
DelReg HKLM\Software\NVIDIA Corporation\NVControlPanel\RegisteredServers\Overrides
DelRegE HKLM\Software\NVIDIA Corporation\NVControlPanel\RegisteredServers
DelReg HKLM\Software\NVIDIA Corporation\NVControlPanel\InstalledClient
DelReg HKLM\Software\NVIDIA Corporation\NVControlPanel\HelpFile
DelReg HKLM\Software\NVIDIA Corporation\NVControlPanel\Client
DelRegE HKLM\Software\NVIDIA Corporation\NVControlPanel
DelRegE HKLM\Software\NVIDIA Corporation

DelReg HKCU\Software\NVIDIA Corporation\NVIDIA Control Panel
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel\RegisteredServers\Overrides
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel\RegisteredServers\DisplayPanelServer
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel\RegisteredServers\GamesConfigServer
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel\RegisteredServers\MobileServer
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel\RegisteredServers\Video_TVServer
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel\RegisteredServers\WorkStationServer
DelRegE HKCU\Software\NVIDIA Corporation\NVControlPanel\RegisteredServers
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel\InstalledClient
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel\HelpFile
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel\Client
DelRegE HKCU\Software\NVIDIA Corporation\NVControlPanel
DelRegE HKCU\Software\NVIDIA Corporation

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

[UninstallPFSedonaClient]
del {ProgramFilesDir}\NVIDIA Corporation\Control Panel Client\nvcplui.exe
del {ProgramFilesDir}\NVIDIA Corporation\Control Panel Client\nvcpluir.dll
del {ProgramFilesDir}\NVIDIA Corporation\Control Panel Client
del {ProgramFilesDir}\NVIDIA Corporation

DelReg HKLM\Software\NVIDIA Corporation\NVIDIA Control Panel
DelReg HKLM\Software\NVIDIA Corporation\NVControlPanel2\RegisteredServers\Overrides
DelRegE HKLM\Software\NVIDIA Corporation\NVControlPanel2\RegisteredServers
DelReg HKLM\Software\NVIDIA Corporation\NVControlPanel2\InstalledClient
DelReg HKLM\Software\NVIDIA Corporation\NVControlPanel2\HelpFile
DelReg HKLM\Software\NVIDIA Corporation\NVControlPanel2\Client
DelRegE HKLM\Software\NVIDIA Corporation\NVControlPanel2
DelReg HKLM\Software\NVIDIA Corporation\NVControlPanel\RegisteredServers2\Dummy
DelRegE HKLM\Software\NVIDIA Corporation\NVControlPanel\RegisteredServers2
DelRegE HKLM\Software\NVIDIA Corporation\NVControlPanel
DelRegE HKLM\Software\NVIDIA Corporation

DelReg HKCU\Software\NVIDIA Corporation\NVIDIA Control Panel
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel2\RegisteredServers\Overrides
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel2\RegisteredServers\DisplayPanelServer
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel2\RegisteredServers\GamesConfigServer
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel2\RegisteredServers\MobileServer
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel2\RegisteredServers\Video_TVServer
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel2\RegisteredServers\WorkStationServer
DelRegE HKCU\Software\NVIDIA Corporation\NVControlPanel2\RegisteredServers
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel2\InstalledClient
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel2\HelpFile
DelReg HKCU\Software\NVIDIA Corporation\NVControlPanel2\Client
DelRegE HKCU\Software\NVIDIA Corporation\NVControlPanel2
DelRegE HKCU\Software\NVIDIA Corporation


DelReg HKCR\CLSID\{0bbca823-e77d-419e-9a44-5adec2c8eeb0}
DelReg HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\ControlPanel\NameSpace\{0bbca823-e77d-419e-9a44-5adec2c8eeb0}
DelReg HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Control Panel\don't load\nvcpl.cpl 

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}
