pal1000 / Realtek-UAD-generic

An unofficial package of generic Realtek Universal Audio Driver made from parts of various OEM specific Reatek Universal Audio drivers intended to work on legacy systems lacking OEM UAD support.
1.13k stars 41 forks source link

Is it possible to restore volume settings after update drivers? #58

Open nkh0472 opened 3 years ago

nkh0472 commented 3 years ago

Every time I use this script to update the driver, the system volume is reset to the default 67% (approximately). And then some warning tone will scare me to death (I usually set the volume at 1~6%). So is it possible to restore volume settings after update drivers?

pal1000 commented 3 years ago

You can try disabling speakers in Sound settings - Manage sound devices before update and re-enable them after update completes. I don't know of a way to preserve volume settings on update unless you want to get your hands dirty and update manually using device manager and force updater only.

nkh0472 commented 3 years ago

First of all, I used the directory monitoring software to monitor the changes of files in the root directory and subdirectory of windows when the volume was changed. The conclusion is that the volume is not obviously saved to a file, but the registry has access records. After that, I adjusted the volume, grabbed the registry dump four times and compared them. The conclusion is that the common key values of registry changes are as follows:

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\VFUProvider
StartTime
90 b9 00 f5 04 c2 d6 01
22 68 c2 18 05 c2 d6 01
12 a9 85 3c 05 c2 d6 01
9f ae 94 cb 05 c2 d6 01
HKU\S-1-5-21-3699173412-3709515503-683509782-1001\Software\Microsoft\InputMethod\SHARED
CoCPrivacyConsentUXShowStartTime
0x5fbc6858(1606183000)
0x5fbc686f(1606183023)
0x5fbc68a9(1606183081)
0x5fbc69b4(1606183348)
HKU\S-1-5-21-3699173412-3709515503-683509782-1001\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{CEBFF5CD-ACE2-4F4F-9178-9926F41749EA}\Count
HRZR_PGYFRFFVBA
03 00 00 00 cf 01 00 00 4b 07 00 00 f2 32 b1 09 58 00 00 00 0e 01 00 00 13 55 38 00 4d 00 69 00 63 00 72 00 6f 00 73 00 6f 00 66 00 74 00 2e 00 57 00 69 00 6e 00 64 00 6f 00 77 00 73 00 2e 00 45 00 78 00 70 00 6c 00 6f 00 72 00 65 00 72 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
03 00 00 00 cf 01 00 00 4c 07 00 00 36 d1 b1 09 58 00 00 00 0e 01 00 00 13 55 38 00 4d 00 69 00 63 00 72 00 6f 00 73 00 6f 00 66 00 74 00 2e 00 57 00 69 00 6e 00 64 00 6f 00 77 00 73 00 2e 00 45 00 78 00 70 00 6c 00 6f 00 72 00 65 00 72 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
03 00 00 00 cf 01 00 00 4f 07 00 00 3b 7c b2 09 58 00 00 00 0e 01 00 00 13 55 38 00 4d 00 69 00 63 00 72 00 6f 00 73 00 6f 00 66 00 74 00 2e 00 57 00 69 00 6e 00 64 00 6f 00 77 00 73 00 2e 00 45 00 78 00 70 00 6c 00 6f 00 72 00 65 00 72 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
03 00 00 00 d0 01 00 00 5b 07 00 00 43 24 b6 09 58 00 00 00 11 01 00 00 29 b7 38 00 4d 00 69 00 63 00 72 00 6f 00 73 00 6f 00 66 00 74 00 2e 00 57 00 69 00 6e 00 64 00 6f 00 77 00 73 00 2e 00 45 00 78 00 70 00 6c 00 6f 00 72 00 65 00 72 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
HKU\S-1-5-21-3699173412-3709515503-683509782-1001\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{CEBFF5CD-ACE2-4F4F-9178-9926F41749EA}\Count
K:\Ertvfgel Jbexfubc\ErtJbexfubcK64.rkr
03 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf ff ff ff ff b0 47 c9 fe 04 c2 d6 01 00 00 00 00
03 00 00 00 01 00 00 00 02 00 00 00 68 98 00 00 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf ff ff ff ff b0 47 c9 fe 04 c2 d6 01 00 00 00 00
03 00 00 00 01 00 00 00 04 00 00 00 67 37 01 00 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf ff ff ff ff b0 47 c9 fe 04 c2 d6 01 00 00 00 00
03 00 00 00 01 00 00 00 09 00 00 00 54 6f 03 00 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf ff ff ff ff b0 47 c9 fe 04 c2 d6 01 00 00 00 00
HKU\S-1-5-21-3699173412-3709515503-683509782-1001\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{CEBFF5CD-ACE2-4F4F-9178-9926F41749EA}\Count
Zvpebfbsg.Jvaqbjf.FuryyRkcrevraprUbfg_pj5a1u2gklrjl!Ncc
03 00 00 00 00 00 00 00 1b 00 00 00 1c e8 c9 00 fa 0d 47 3c 44 d2 df 3e 8a 9e d8 3d 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
03 00 00 00 00 00 00 00 1b 00 00 00 f8 ed c9 00 fa 0d 47 3c 44 d2 df 3e 8a 9e d8 3d 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
03 00 00 00 00 00 00 00 1c 00 00 00 fe f9 c9 00 fa 0d 47 3c 44 d2 df 3e 8a 9e d8 3d 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
03 00 00 00 00 00 00 00 1d 00 00 00 00 11 ca 00 fa 0d 47 3c 44 d2 df 3e 8a 9e d8 3d 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 00 00 80 bf 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

It doesn't seem to show any regularity.

After that, I found that windows provided the corresponding API: IAudioEndpointVolume::GetMasterVolumeLevelScalar method IAudioEndpointVolume::SetMasterVolumeLevel

I thought that PowerShell should be able to call these APIs, so I Googled "PowerShell set windows volume" and found this: Change audio level from powershell? There are many PowerShell scripts that can get the current volume and set the volume. I think that simply pasting it into this project may work.

I'm not very familiar with windows scripting, but I think these can help you.