AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1503161
Accepted
raddevus
raddevus
Asked: 2019-11-19 10:44:40 +0800 CST2019-11-19 10:44:40 +0800 CST 2019-11-19 10:44:40 +0800 CST

如何在 X 分钟后阻止 Windows 虚拟机自动锁屏?

  • 772

我通过(mstsc - 我的 Win10 机器上的远程桌面)连接到多个 VMWare 实例。最近,在 Windows 更新或可能的策略更改后,所有虚拟机在 X 分钟后屏幕锁定(我猜该值为 10)。

我试过的

我已经更改了注册表并添加了值 NoLockScreen,然后我重新启动了,但机器仍然锁定:(在https://www.cnet.com/how-to/how-to-disable-找到解决方案the-Windows-10-lock-screen/。

注册地点:

\\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Personalization

无锁屏

尽管不同的虚拟机正在运行 2012 R2、Server 2016 和基本的 Win10,但所有各种 Windows 机器似乎都已锁定。

都在同一个域上

所有虚拟机和我的客户端都在同一个域上运行。我的客户(我远程到虚拟机的地方)是:

赢版

这个问题导致我每次都必须在我连接的多台机器上输入我的密码——完全浪费时间。

有没有其他方法可以解决这个问题?

windows virtual-machine
  • 2 2 个回答
  • 4127 Views

2 个回答

  • Voted
  1. M. A.
    2019-11-19T11:48:33+08:002019-11-19T11:48:33+08:00

    根据您的问题和评论,这里是回复


    交互式登录:机器不活动限制

    这是自 Windows 8 开始的安全策略,也适用于 Windows 10。

    Windows 会注意到登录会话处于不活动状态,如果不活动时间超过不活动限制,则会出现锁定屏幕,锁定会话。

    默认值:不强制。

    如何改变它?

    • 点击⊞ Win按钮。
    • 键入本地安全策略
    • 请按照以下 imgae 上的说明进行操作:

    在此处输入图像描述

    PS:如果您是本地管理员,您可以从Local Security Policy更改它,否则帮助台管理员可以为您修改它

    来源:Microsoft Docs-交互式登录:机器不活动限制

    • 2
  2. Best Answer
    raddevus
    2019-11-20T11:27:49+08:002019-11-20T11:27:49+08:00

    如果您没有管理员权限

    如果您没有管理员权限来进行已接受解决方案中显示的更改,则可以通过自动化方式解决此问题。

    每次我的各种虚拟机之一被锁定时都必须输入密码真的很烦人,所以我编写了这个在 LINQPad 中运行的 C# 脚本(在linqpad.net获取免费副本)。

    // #######################################################
    // ####  Must include the two following libraries
    // ####  using System.Diagnostics
    // #### using System.Runtime.InteropServices
    
    [DllImport("user32.dll")]
    private static extern bool SetForegroundWindow(IntPtr hWnd);
    
    [DllImport("user32.dll", CharSet=CharSet.Auto,ExactSpelling=true)]
    private static extern IntPtr SetFocus(HandleRef hWnd);
    
    [DllImport("user32.dll")]
    static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
    
    void Main()
    {
        InitializeTimer();
        RescanTimer.Start();
    }
    System.Timers.Timer RescanTimer = new System.Timers.Timer();
    private void InitializeTimer()
    {
        // ## The timer will run the code every 10 seconds (10000ms).
        // ##  You can change it to whatever interval you like that is 
        // ##  shorter than your LockScreen time
        RescanTimer.Interval = 10000D;
        RescanTimer.Elapsed += RescanTimer_Elapsed;
    }
    
    protected void RescanTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
    {
        try{
            //Stop timer each time, while the elapsed function runs.
            RescanTimer.Stop();
            Process[] processlist = Process.GetProcesses();
            Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            foreach (Process process in processlist)
            {
                if (!String.IsNullOrEmpty(process.MainWindowTitle))
                {
                    if (process.ProcessName.Contains("mstsc")){
                    // ## finds processes which are mstsc and gets associated main window
                        Console.WriteLine("Process: {0} ID: {1} Window title: {2}", process.ProcessName, process.Id, process.MainWindowTitle);
                        SetForegroundWindow(process.MainWindowHandle);
                        SetFocus(new HandleRef(null, process.MainWindowHandle));
                        ShowWindow(process.MainWindowHandle, 1);
                    }
                }
            }
            Console.WriteLine();
        }
        finally{
            // ## Insure that even if the elapsed function fails, 
            // ## the timer is still restarted.
            RescanTimer.Start();
        }
    }
    

    工作解决方案

    我已经运行这段代码几个小时了,我发现:

    1. 它不使用任何明显的 CPU
    2. 关联的 VM 屏幕均未锁定
    3. 它不会打断您或将您的注意力转移到另一个屏幕(当我输入这个答案时,代码运行了很多次而没有中断)

    创建一个单独的应用程序

    当然,如果您愿意,您可以使用该代码并为自己编写一个小的 .exe,这样您就不必运行 LINQPad。

    输出主要用于测试

    控制台输出主要用于我的测试。它将如下所示(您的进程 ID 和计算机名称显然会有所不同):

    输出示例

    • 1

相关问题

  • virtualbox 是否需要 CPU 来支持 VT-d 以托管 64 位客户操作系统?

  • Python 的“pass”参数的批处理等价物是什么?

  • 在 Windows 上与 Docker 守护进程通信

  • VMware Workstation USB 仲裁服务无法自动启动

  • 资源管理器侧面板中的桌面外壳快捷方式

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    Windows 10 服务称为 AarSvc_70f961。它是什么,我该如何禁用它?

    • 2 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Marko Smith

    ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1056)

    • 4 个回答
  • Marko Smith

    我如何知道 Windows 安装在哪个驱动器上?

    • 6 个回答
  • Martin Hope
    Albin 支持结束后如何激活 WindowsXP? 2019-11-18 03:50:17 +0800 CST
  • Martin Hope
    fixer1234 “HTTPS Everywhere”仍然相关吗? 2019-10-27 18:06:25 +0800 CST
  • Martin Hope
    Kagaratsch Windows 10 删除大量小文件的速度非常慢。有什么办法可以加快速度吗? 2019-09-23 06:05:43 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    Inter Sys Ctrl+C 和 Ctrl+V 是如何工作的? 2019-05-15 02:51:21 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve