【问题标题】:Refresh screen every 5 mins [closed]每5分钟刷新一次屏幕[关闭]
【发布时间】:2017-06-11 04:25:05
【问题描述】:

我有一个windows服务器,我曾经通过远程桌面连接,但是如果我让它闲置就会被锁定,而且我无法更改远程桌面选项的超时时间,所以我想写一个 批处理文件vbscriptpowershell 将在 Windows 服务器中运行并刷新自身 (F5) 或鼠标单击或鼠标移动,例如每 5 分钟。

server 2008 R2 entreprise 64-bit

【问题讨论】:

  • 您可以查看使用 VBscript 并使用 SENDKEYS 方法。我确信 powershell 具有类似的功能,但批处理文件没有。
  • 我在类似的环境中使用过这个工具。 mousejiggler.codeplex.com 这是一个 TINY 二进制文件,它会不时晃动虚拟鼠标。
  • 你应该用 vbscript 来做
  • 我的答案已经为你准备好了,所以,如果你想要它在 vbscript 中,只需 edit 你的问题并添加标签 vbscript
  • @Hackoo 添加了 vbscript

标签: windows powershell batch-file vbscript windows-server-2008


【解决方案1】:

试试这个 vbscript:

Option Explicit
If AppPrevInstance() Then 
    MsgBox "There is an existing proceeding !" & VbCrLF &_
    CommandLineLike(WScript.ScriptName),VbExclamation,"There is an existing proceeding !"    
    WScript.Quit  
Else   
    Dim Ws
    set Ws = createobject("Wscript.Shell")
    Do
        Ws.Sendkeys "{F5}"
        Pause 5 '==> To sleep for 5 minutes
    Loop
End If   
'**************************************************************************
Function AppPrevInstance()   
    With GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")   
        With .ExecQuery("SELECT * FROM Win32_Process WHERE CommandLine LIKE " & CommandLineLike(WScript.ScriptFullName) & _
        " AND CommandLine LIKE '%WScript%' OR CommandLine LIKE '%cscript%'")   
            AppPrevInstance = (.Count > 1)   
        End With   
    End With   
End Function   
'**************************************************************************
Function CommandLineLike(ProcessPath)   
    ProcessPath = Replace(ProcessPath, "\", "\\")   
    CommandLineLike = "'%" & ProcessPath & "%'"   
End Function
'**************************************************************************
Sub Pause(min)
    Wscript.Sleep(min*1000*60)
End sub
'**************************************************************************

【讨论】:

    猜你喜欢
    • 2013-11-17
    • 2012-06-30
    • 2016-11-10
    • 2019-08-18
    • 1970-01-01
    • 1970-01-01
    • 2020-06-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多