Windows 每5分钟刷新一次屏幕
我有一个windows服务器,我以前通过远程桌面连接它,但是如果我让它闲置,它会被锁定,并且我无法更改远程桌面选项的超时,因此,我想编写一个批处理文件或vbscript或powershell,它将在windows服务器上运行并刷新自身(F5),或者像每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
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