Working principle: when a button on HMI (Human Machine Interface) is pressed, it will open an external program. If the same button is pressed again, it will close the program. It works like a flip-flop command. If I use the command "StartProgram", it opens the program, but I don't know how to close the program. I sought a command like "StopProgram" or "CloseProgram", but I wonder it doesn't exist.
So, I'm trying to make this works through a code I've seen on the internet, but unsuccessfully. Below, my code:
Dim PCI
Set PCI = CreateObject("WScript.Shell")
If SmartTags("Flag Abrir PCI") = 1 Then
PCI.Run """C:\pret\PCI.exe"" -p1 -c"
End If
If SmartTags("Flag Abrir PCI") = 0 Then
PCI.Run "taskkill /F /IM PCI.exe", , True
End If
Could anyone give me a tip to make it work, please?
When I only write the code below, it opens, but don't know how to close it.
StartProgram "C:\pret\PCI.exe", "", hmiShowNormal, hmiNo
The code you have posted is proprietary code used by WinCC Professional which is a Siemens product. See the Official Documentation for more information.
Just from a brief look through the documentation, it looks like the
StopRuntime
command is what you are looking for.