Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 每5分钟刷新一次屏幕_Windows_Powershell_Batch File_Vbscript_Windows Server 2008 - Fatal编程技术网

Windows 每5分钟刷新一次屏幕

Windows 每5分钟刷新一次屏幕,windows,powershell,batch-file,vbscript,windows-server-2008,Windows,Powershell,Batch File,Vbscript,Windows Server 2008,我有一个windows服务器,我以前通过远程桌面连接它,但是如果我让它闲置,它会被锁定,并且我无法更改远程桌面选项的超时,因此,我想编写一个批处理文件或vbscript或powershell,它将在windows服务器上运行并刷新自身(F5),或者像每5分钟一样单击鼠标或移动鼠标 server 2008 R2 entreprise 64-bit 请尝试使用此vbscript: Option Explicit If AppPrevInstance() Then MsgBox "Ther

我有一个windows服务器,我以前通过远程桌面连接它,但是如果我让它闲置,它会被锁定,并且我无法更改远程桌面选项的超时,因此,我想编写一个批处理文件vbscriptpowershell,它将在windows服务器上运行并刷新自身(F5),或者像每5分钟一样单击鼠标或移动鼠标

server 2008 R2 entreprise 64-bit

请尝试使用此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
'**************************************************************************

您可以看看如何使用VBscript和SENDKEYS方法。我确信powershell具有类似的功能,但批处理文件没有。我在类似的环境中使用过此工具。这是一个很小的二进制文件,它每隔一段时间就会摇动一个虚拟鼠标。你应该用vbscript来做。我的答案已经为你准备好了,所以,如果你想在vbscript中找到答案,只需回答你的问题并添加标记即可vbscript@Hackoo添加了vbscript