Win 10 外接电源无法睡眠

尝试关闭离开模式:

计算机HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerPowerAwayModeEnable

可以管理员方式在 wscript 中执行以下 JS。

reg.js

/**
 * reg.js
 * @license GLPv3.0
 * @author YanWen <i@yanwen.email>
 * @modifiedAt 2018/10/04
 * @NOTE http://www.informit.com/articles/article.aspx?p=1187429&seqNum=5
 */

var Reg = {
  title: 'Reg Script',
  shell: WScript.CreateObject('WScript.Shell'),

  read: function (reg) {
    try {
      Reg.shell.Popup('Read ' + reg + ': ' +
        Reg.shell.RegRead(reg).toString(), 0, Reg.title, 64);
    } catch (e) {
      Reg.shell.Popup(e.message, 0, Reg.title, 16);
    }
  },

  write: function (reg, val, type) {
    try {
      Reg.shell.Popup('Write: ' + reg + ': ' +
        Reg.shell.RegWrite(reg, val, type), 0, Reg.title, 64);
    } catch (e) {
      Reg.shell.Popup(e.message, 0, Reg.title, 16);
    }
  },

  del: function (reg) {
    try {
      Reg.shell.Popup('Del: ' + reg + ': ' +
        Reg.shell.RegDelete(reg), 0, Reg.title, 64);
    } catch (e) {
      Reg.shell.Popup(e.message, 0, Reg.title, 16);
    }
  }
};

var reg = 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Power\AwayModeEnable';

Reg.read(reg);
Reg.write(reg, 0, 'REG_DWORD')
Reg.read(reg);

参考:

  1. http://www.informit.com/articles/article.aspx?p=1187429&seqNum=5

作者: YanWen

Web 开发者

发表评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

You are commenting using your WordPress.com account. Log Out /  更改 )

Google photo

You are commenting using your Google account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )

Connecting to %s