You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:通过脚本模拟用户输入保持Citrix Windows 10 VDI持续运行

防止Citrix VDI闲置断开的脚本方案

PowerShell脚本(模拟鼠标微动)

该脚本每隔90分钟将鼠标移动1像素后移回原位,避免系统判定为闲置状态。

# 引入Windows API控制鼠标
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class MouseMove {
    [DllImport("user32.dll")]
    public static extern bool SetCursorPos(int X, int Y);
}
"@

# 循环执行鼠标微动
while ($true) {
    # 获取当前鼠标位置
    $pos = [System.Windows.Forms.Cursor]::Position
    # 向右移动1像素
    [MouseMove]::SetCursorPos($pos.X + 1, $pos.Y)
    Start-Sleep -Milliseconds 100
    # 移回原位置
    [MouseMove]::SetCursorPos($pos.X, $pos.Y)
    # 等待90分钟
    Start-Sleep -Seconds 5400
}

使用说明

  1. 将代码保存为PreventIdle.ps1
  2. 右键以管理员身份运行PowerShell,执行命令:.\PreventIdle.ps1
  3. 如需后台自动运行,可创建Windows任务计划,设置为登录后启动,重复间隔设为90分钟

VBScript脚本(模拟按键输入)

该脚本每隔1小时发送一次Scroll Lock按键信号,触发系统判定为有用户操作。

Set WshShell = CreateObject("WScript.Shell")

Do
    # 发送Scroll Lock按键(按下再松开)
    WshShell.SendKeys "{SCROLLLOCK}"
    WScript.Sleep 100
    WshShell.SendKeys "{SCROLLLOCK}"
    # 等待1小时
    WScript.Sleep 3600000
Loop

使用说明

  1. 将代码保存为PreventIdle.vbs
  2. 双击即可运行,脚本会在后台持续执行
  3. 如需关闭,打开任务管理器结束wscript.exe进程即可

内容的提问来源于stack exchange,提问作者CodeBot

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 06:52:18