I'm new to VBS and have to use a small script, that activates a programm called PlantSimulation13.exe and then presses enter. It works fine on my computer and It works fine on a remote-desktop as long as I'm logged in as well. If I'm not logged in it doesn't seem to do anything.
I have to use it to automatically answer a Messagebox. The script is run by the Programm PlantSimulation itself.
This is the script:
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}"
Does anyone know why it doesn't work when I'm not "watching" it on the remote-desktop?