File tree Expand file tree Collapse file tree 5 files changed +86
-0
lines changed
Expand file tree Collapse file tree 5 files changed +86
-0
lines changed Original file line number Diff line number Diff line change 1+ ### Driver 驱动
Original file line number Diff line number Diff line change 1+ ---
2+ sidebar_position : 1
3+ ---
4+
5+ ### Permission 权限
6+
7+ ![ ] ( imgs\UAC.png )
8+
9+ 在使用GeneralUpdate实现自动升级的时候,如果更新目录在C盘实现文件替换或打文件补丁时会出现权限问题。又因为windows11操作系统推出在C盘特定的目录相比之前推出的windows的操作系统加强了权限管理。
10+
11+ 那么稍微不注意将会触碰到权限管理的边界,接下来我们看看操作哪些目录会导致出现权限问题:
12+
13+ | 名称 | 目录 |
14+ | -------------- | ------------------------------------------ |
15+ | 系统文件夹 | C:\Windows |
16+ | 注册表配置文件 | C:\Windows\System32\config |
17+ | 驱动文件夹 | C:\Windows\System32\drivers |
18+ | 程序文件夹 | C:\Program Files 和 C:\Program Files (x86) |
19+
20+ 推荐使用目录,避免权限问题:
21+
22+ | 名称 | 目录 |
23+ | ------------ | ------- |
24+ | 用户数据目录 | AppData |
25+ | 系统临时目录 | Temp |
26+
27+
28+
29+ ### UAC降权
30+
31+ 以下方法不推荐在生产环境中使用,以免给用户造成损失。如果在更新过程中出现UAC (User Account Control)提示或无权限、拒绝访问的情况可以考虑降低UAC控制等级,这个思路在代码层面可以通过修改以下注册表达到目的:
32+
33+ | 注册表名称 | 修改值 | 默认值 |
34+ | -------------------------- | ------ | ------ |
35+ | enableLUA | 0 | 1 |
36+ | ConsentPromptBehaviorAdmin | 0 | 5 |
37+
38+ 更新之前修改以上注册表(重启计算机生效),切记更新完成之后需要恢复该内容。
39+
40+
41+
42+ c#修改注册表:
43+
44+ ``` c#
45+ using Microsoft .Win32 ;
46+
47+ public void UpdateRegistry ()
48+ {
49+ const string keyName = @" SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" ;
50+
51+ using (RegistryKey key = Registry .LocalMachine .OpenSubKey (keyName , true ))
52+ {
53+ if (key != null )
54+ {
55+ key .SetValue (" EnableLUA" , 0 , RegistryValueKind .DWord );
56+ key .SetValue (" ConsentPromptBehaviorAdmin" , 0 , RegistryValueKind .DWord );
57+ }
58+ }
59+ }
60+ ```
61+
62+
63+
64+ bat批处理修改注册表:
65+
66+ ``` bat
67+ @echo off
68+ REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableLUA /t REG_DWORD /d 0 /f
69+ REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /f
70+ ```
71+
72+
73+
74+ 参考内容:
75+
76+ - https://learn.microsoft.com/zh-cn/windows/security/application-security/application-control/user-account-control/how-it-works
77+ - https://blog.walterlv.com/post/windows-user-account-control.html
Original file line number Diff line number Diff line change 1+ {
2+ "label" : " Guide" ,
3+ "position" : 1 ,
4+ "link" : {
5+ "type" : " generated-index" ,
6+ "description" : " 指南."
7+ }
8+ }
You can’t perform that action at this time.
0 commit comments