|
发表于 2019-3-24 12:18
来自手机
|
显示全部楼层
本帖最后由 lss001 于 2019-3-25 02:22 编辑
'win10修改系统注册表需要管理员权限!
'那么普通用户如何才能获得管理员权限呢?
'其实微软已经为普通用户预留了API函数接口ShellExecut!以下是示范:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Sub SHChangeNotify Lib "shell32.dll" _
(ByVal wEventId As Long, ByVal uFlags As Long, ByVal dwItem1 As Long, ByVal dwItem2 As Long)
Private Const SHCNE_ASSOCCHANGED = &H8000000, SHCNF_IDLIST = &H0
Sub zcbcz() '注册表中修改UAC(用户账户控制)
'通知级别:211/UAC高,511/UAC中(系统默认),510/UAC低,000/UAC关闭,111/UAC密码
'以下修改注册表511/UAC中(系统默认)
skey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
ShellExecute 0, "runas", "cmd.exe", "/c reg add " & skey & " /v ""ConsentPromptBehaviorAdmin"" /t reg_dword /d 5 /f", 0, 0
ShellExecute 0, "runas", "cmd.exe", "/c reg add " & skey & " /v ""EnableLUA"" /t reg_dword /d 1 /f", 0, 0
ShellExecute 0, "runas", "cmd.exe", "/c reg add " & skey & " /v ""PromptOnSecureDesktop"" /t reg_dword /d 1 /f", 0, 0
'其中runas管理员身份,cmd.exe命令程序,/c隐藏命令窗口,reg add修改注册表,skey注册表路径,/v……名称,/t……类型,/d……数据,/f强制执行
Call SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0) '立即刷新系统注册表即刻生效!
End Sub
|
评分
-
2
查看全部评分
-
|