我是 VBS 新手,必须使用一个小脚本来激活一个名为 PlantSimulation13.exe 的程序,然后按 Enter。它在我的计算机上运行良好,并且只要我也登录,它在远程桌面上运行良好。如果我没有登录,它似乎什么也没做。
我必须用它来自动回答一个消息框。该脚本由 Programm PlantSimulation 本身运行。
这是脚本:
Dim fsShell
Set fsShell = WScript.CreateObject("WScript.Shell")
Set Processes = GetObject("winmgmts:").InstancesOf("Win32_Process")
WScript.Sleep 4000
For Each Process In Processes
If StrComp(Process.Name, "PlantSimulation13.exe", vbTextCompare) = 0 Then
With CreateObject("WScript.Shell")
.AppActivate Process.ProcessId
End With
Exit For
End If
Next
fsShell.SendKeys "{ENTER}"
有谁知道为什么当我不在远程桌面上“观看”它时它不起作用?