每 5 分钟刷新一次屏幕
Refresh screen every 5 mins
我有 windows 我曾经通过远程桌面连接的服务器,但如果我闲置它就会被锁定,而且我无法更改远程桌面选项的超时时间,所以我想要写一个 批处理文件 或 vbscript 或 powershell 这将 运行 在 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
'**************************************************************************
我有 windows 我曾经通过远程桌面连接的服务器,但如果我闲置它就会被锁定,而且我无法更改远程桌面选项的超时时间,所以我想要写一个 批处理文件 或 vbscript 或 powershell 这将 运行 在 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
'**************************************************************************