Join us today!
Close TwinCAT HMI application using button on HMI
It is sometimes necessary to access the IPC desktop for various reasons, and when launching the HMI application in full screen that can become troublesome, especially without having a keyboard present on site.
Setting up an HMI button that terminates the HMI application if needed can be very handy.
This method uses NT_StartProcess of the TC_Utilities library, advantage is that no .bat file is needed.
STEPS
- Create a button on HMI to toggle a Boolean variable (in this example "Var : Close")
- Use the following code:
PROGRAM MAIN VAR Close: BOOL; closeChrome : NT_StartProcess; END_VAR ************************************** closeChrome( NetId := '', PathStr := 'C:\Windows\System32\mshta vbscript:Execute("CreateObject(""WScript.Shell"").Run ""powershell -c', DirName := 'C:\Windows\System32\WindowsPowerShell\v1.0', ComndLine := 'taskkill /F /IM chrome.exe /T"", 0: window.close")', Start := Close, TmOut := DEFAULT_ADS_TIMEOUT ); Close:= FALSE;
That is greatly helpful, thank you 🙂
Is there a solution for PLC HMI as well?
@unchained I have never tried it with PLC HMI, but in theory it should work as all this is doing is "Killing" a specific task, in my case it's Chrome.
Try changing the command line argument "IM chrome.exe" with the PLC HMI task and see if it works.
We did something quite similar using NT_StartProcess too. This was the config we used.
PATHSTR := 'C:\Windows\System32\cmd.exe'
COMNDLINE := '/C taskkill /f /im "chrome.exe"'
This also kills chrome.
I am using BAT files today that i trigger from the NT process.
But after reading this topic i wounder if i can write my BAT file command direct in the NT start FB.
Can someone help me with this topic?
The code in my BAT file today looks like this
------------------------------------------------------------------------
CD C:\OMRON\FZ_FH_FJ_Simulator\FHVX-XXX_631
start FZ-RemoteClient.exe 192.168.255.34 0 1280x1
exit
------------------------------------------------------------------------
Thanks
- 17 Forums
- 267 Topics
- 942 Posts
- 0 Online
- 722 Members