簡體   English   中英

遠程桌面Powershell腳本

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM