[英]Remote Desktop Powershell Script
我刚刚订购了运行Windows Server的VPS。 该服务器唯一需要做的是运行Powershell脚本,该脚本具有无限循环( while($true)
),其中包含一些代码。
通常,如果我通过远程桌面连接到VPS,则一切运行正常,并且可以正常运行。 但是,每当我退出远程桌面时,Powershell脚本就会暂停,并且直到我再次连接后才继续。
有什么办法可以使脚本“永久”,因此退出远程桌面会话时它不会停止吗?
这是Powershell脚本:
while($true)
{
Start-Sleep 2
start chrome.exe
Start-Sleep 2
Invoke-Item C:\Users\me\index.html
Start-Sleep 2
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
Start-Sleep 1000
[System.Windows.Forms.SendKeys]::SendWait("%{F4}")
Start-Sleep 2
[System.Windows.Forms.SendKeys]::SendWait("%{F4}")
}
顺便说一句,我从Powershell ISE启动脚本,而不是直接执行脚本,因为那样一来它就不知道上下文SendKeys,但是我认为不应更改任何内容,对吗?
PowerShell不会在断开连接的会话中暂停,但是SendKeys
在断开连接的会话中不起作用。 这是预期的行为。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.