1

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?

Niklas R
  • 11
  • 2
  • Welcome to [so]. See my answer to this question for an explanation and details on a fix: https://stackoverflow.com/questions/48462964/sendkeys-in-remote-minimized-machine-vbs – Dave Aug 29 '18 at 09:04
  • Thank you very much for your answers. This seems to be a similar issue. Does the solution also affect the behavior when I completely shut the remote connection or does this only work for minimizing the remote window? Unfortunetaly I can't test the solution without a certain effort, since I don't have the permission to change something in the registry editor on the computer I use. – Niklas R Aug 29 '18 at 10:19

0 Answers0