找回密码
 加入
搜索
查看: 3551|回复: 8

[系统综合] 某些注册表键值无法修改。(是不是需要获取system权限呢?)

  [复制链接]
发表于 2016-5-11 11:14:08 | 显示全部楼层 |阅读模式
某些注册表键值无法修改。是不是需要获取system权限呢?
以下脚本在win10中无法成功修改注册表键值。请大神帮忙解决问题吗?
#RequireAdmin
#include <Process.au3>


If @OSVersion <> 'WIN_XP' And  @OSVersion <> 'WIN_2003' Then ;对xp 2003系统不修改


        ; 脚本功能: 按电源开关设置为:关机;睡眠键:不作为;关盖:关机
        $power = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\Default\PowerSchemes', 'ActivePowerScheme')
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\7648efa3-dd9c-4e3e-b566-50f929386280', 'DCSettingIndex', 'REG_DWORD', 3)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\7648efa3-dd9c-4e3e-b566-50f929386280', 'ACSettingIndex', 'REG_DWORD', 3)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\a1841308-3541-4fab-bc81-f71556f20b4a\4f971e89-eebd-4455-a8de-9e59040e7347\7648efa3-dd9c-4e3e-b566-50f929386280', 'DCSettingIndex', 'REG_DWORD', 3)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\a1841308-3541-4fab-bc81-f71556f20b4a\4f971e89-eebd-4455-a8de-9e59040e7347\7648efa3-dd9c-4e3e-b566-50f929386280', 'ACSettingIndex', 'REG_DWORD', 3)
        $power = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes', 'ActivePowerScheme')
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\7648efa3-dd9c-4e3e-b566-50f929386280', 'DCSettingIndex', 'REG_DWORD', 3)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\7648efa3-dd9c-4e3e-b566-50f929386280', 'ACSettingIndex', 'REG_DWORD', 3)

        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\96996bc0-ad50-47ec-923b-6f41874dd9eb', 'DCSettingIndex', 'REG_DWORD', 0)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\96996bc0-ad50-47ec-923b-6f41874dd9eb', 'ACSettingIndex', 'REG_DWORD', 0)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\a1841308-3541-4fab-bc81-f71556f20b4a\4f971e89-eebd-4455-a8de-9e59040e7347\96996bc0-ad50-47ec-923b-6f41874dd9eb', 'DCSettingIndex', 'REG_DWORD', 0)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\a1841308-3541-4fab-bc81-f71556f20b4a\4f971e89-eebd-4455-a8de-9e59040e7347\96996bc0-ad50-47ec-923b-6f41874dd9eb', 'ACSettingIndex', 'REG_DWORD', 0)
        $power = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes', 'ActivePowerScheme')
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\96996bc0-ad50-47ec-923b-6f41874dd9eb', 'DCSettingIndex', 'REG_DWORD', 0)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\96996bc0-ad50-47ec-923b-6f41874dd9eb', 'ACSettingIndex', 'REG_DWORD', 0)

        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\5ca83367-6e45-459f-a27b-476b1d01c936', 'DCSettingIndex', 'REG_DWORD', 3)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\5ca83367-6e45-459f-a27b-476b1d01c936', 'ACSettingIndex', 'REG_DWORD', 3)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\a1841308-3541-4fab-bc81-f71556f20b4a\4f971e89-eebd-4455-a8de-9e59040e7347\5ca83367-6e45-459f-a27b-476b1d01c936', 'DCSettingIndex', 'REG_DWORD', 3)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\a1841308-3541-4fab-bc81-f71556f20b4a\4f971e89-eebd-4455-a8de-9e59040e7347\5ca83367-6e45-459f-a27b-476b1d01c936', 'ACSettingIndex', 'REG_DWORD', 3)
        $power = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes', 'ActivePowerScheme')
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\5ca83367-6e45-459f-a27b-476b1d01c936', 'DCSettingIndex', 'REG_DWORD', 3)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\5ca83367-6e45-459f-a27b-476b1d01c936', 'ACSettingIndex', 'REG_DWORD', 3)
        ; 脚本功能: 按电源开关设置为:关机;睡眠键:不作为;关盖:关机
        $power = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\Default\PowerSchemes', 'ActivePowerScheme')
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\7648efa3-dd9c-4e3e-b566-50f929386280', 'DCSettingIndex', 'REG_DWORD', 3)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\7648efa3-dd9c-4e3e-b566-50f929386280', 'ACSettingIndex', 'REG_DWORD', 3)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes\a1841308-3541-4fab-bc81-f71556f20b4a\4f971e89-eebd-4455-a8de-9e59040e7347\7648efa3-dd9c-4e3e-b566-50f929386280', 'DCSettingIndex', 'REG_DWORD', 3)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes\a1841308-3541-4fab-bc81-f71556f20b4a\4f971e89-eebd-4455-a8de-9e59040e7347\7648efa3-dd9c-4e3e-b566-50f929386280', 'ACSettingIndex', 'REG_DWORD', 3)
        $power = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes', 'ActivePowerScheme')
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\7648efa3-dd9c-4e3e-b566-50f929386280', 'DCSettingIndex', 'REG_DWORD', 3)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\7648efa3-dd9c-4e3e-b566-50f929386280', 'ACSettingIndex', 'REG_DWORD', 3)

        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\96996bc0-ad50-47ec-923b-6f41874dd9eb', 'DCSettingIndex', 'REG_DWORD', 0)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\96996bc0-ad50-47ec-923b-6f41874dd9eb', 'ACSettingIndex', 'REG_DWORD', 0)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes\a1841308-3541-4fab-bc81-f71556f20b4a\4f971e89-eebd-4455-a8de-9e59040e7347\96996bc0-ad50-47ec-923b-6f41874dd9eb', 'DCSettingIndex', 'REG_DWORD', 0)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes\a1841308-3541-4fab-bc81-f71556f20b4a\4f971e89-eebd-4455-a8de-9e59040e7347\96996bc0-ad50-47ec-923b-6f41874dd9eb', 'ACSettingIndex', 'REG_DWORD', 0)
        $power = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes', 'ActivePowerScheme')
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\96996bc0-ad50-47ec-923b-6f41874dd9eb', 'DCSettingIndex', 'REG_DWORD', 0)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\96996bc0-ad50-47ec-923b-6f41874dd9eb', 'ACSettingIndex', 'REG_DWORD', 0)

        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\5ca83367-6e45-459f-a27b-476b1d01c936', 'DCSettingIndex', 'REG_DWORD', 3)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\5ca83367-6e45-459f-a27b-476b1d01c936', 'ACSettingIndex', 'REG_DWORD', 3)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes\a1841308-3541-4fab-bc81-f71556f20b4a\4f971e89-eebd-4455-a8de-9e59040e7347\5ca83367-6e45-459f-a27b-476b1d01c936', 'DCSettingIndex', 'REG_DWORD', 3)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes\a1841308-3541-4fab-bc81-f71556f20b4a\4f971e89-eebd-4455-a8de-9e59040e7347\5ca83367-6e45-459f-a27b-476b1d01c936', 'ACSettingIndex', 'REG_DWORD', 3)
        $power = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes', 'ActivePowerScheme')
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\5ca83367-6e45-459f-a27b-476b1d01c936', 'DCSettingIndex', 'REG_DWORD', 3)
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\User\PowerSchemes\' & $power & '\4f971e89-eebd-4455-a8de-9e59040e7347\5ca83367-6e45-459f-a27b-476b1d01c936', 'ACSettingIndex', 'REG_DWORD', 3)

        
ProcessClose("explorer.exe") ;结束explorer.exe进程,经测试,会自动再次启动,相当于刷新了下桌面。
While Not WinExists('[CLASS:Progman]')
        Sleep(100)
WEnd

endif
发表于 2016-5-13 22:42:37 | 显示全部楼层
XP系统的话试试内置程序 regini.exe,win7以上系统就不知道了!
 楼主| 发表于 2016-5-15 10:55:23 | 显示全部楼层
回复 2# chishingchan


    我需要在win10里修改这个键值
发表于 2016-5-15 11:50:55 | 显示全部楼层
用系统管理员身份
 楼主| 发表于 2016-5-15 18:06:40 | 显示全部楼层
回复 4# Netfox


    已经用了#RequireAdmin,已经是管理员了,现在需要的是system权限。
发表于 2016-5-15 20:24:15 | 显示全部楼层
回复 3# leo005


    win10 里有没有 regini.exe 程序?你搜一下,有的话就可以解决问题!
发表于 2016-5-16 19:19:38 | 显示全部楼层
大概看了你要实现的功能,其实可以把电源方案导出成一个文件,直接导入就可以了,不用这么复杂。

导出电源方案:powercfg /export
导入电源方案:powercfg /import
自己看帮助吧。

以下是我自己用到的,@ScriptDir & "\Other\power.pow"是我自己导出的电源方案
Func _PowerCfg($Mode)                                                        ;电源设置
   $GUID = "00000000-0000-0000-0000-000000000000"
   $PowerCfg = @ScriptDir & "\Other\power.pow"

   If $Mode = 1 Then                        ;修改电源选项,关闭屏幕休眠,关闭屏幕保护
          ;RunWait(@ComSpec & " /c " & 'powercfg -H OFF', "", @SW_HIDE)                        ;
          RunWait(@ComSpec & " /c " & 'powercfg -s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c', "", @SW_HIDE)                        ;将"高性能"电源选项设为活动的
          RunWait(@ComSpec & " /c " & 'powercfg -d ' & $GUID, "", @SW_HIDE)                                                                                ;删除创建的电源选项

          RunWait(@ComSpec & " /c " & 'powercfg -import ' & $PowerCfg & ' ' & $GUID, "", @SW_HIDE)                                ;创建一个电源选项
          RunWait(@ComSpec & " /c " & 'powercfg -s ' & $GUID, "", @SW_HIDE)                                                                                ;将创建的电源选项设为活动的
   ElseIf $Mode = 2 Then                ;恢复默认设置
          ;RunWait(@ComSpec & " /c " & 'powercfg -H ON', "", @SW_HIDE)                        ;
          RunWait(@ComSpec & " /c " & 'powercfg -s 381b4222-f694-41f0-9685-ff5bb260df2e', "", @SW_HIDE)                        ;将"平衡"电源选项设为活动的
          RunWait(@ComSpec & " /c " & 'powercfg -d ' & $GUID, "", @SW_HIDE)                                                                                ;删除创建的电源选项
   EndIf
EndFunc
发表于 2016-5-16 19:21:02 | 显示全部楼层
回复 5# leo005

检查下是不是64位系统
Local $OSArch = ""
If @OSArch = "x64" Then $OSArch = "64"

If RegRead("HKLM" & $OSArch & "\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "EnableLUA") = 1 。。。
 楼主| 发表于 2016-5-17 10:57:39 | 显示全部楼层
回复 7# yhxhappy


    非常感谢,马上去试试
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-26 00:53 , Processed in 0.074969 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表