Join us today!

Close TwinCAT HMI a...
 
Notifications
Clear all

Close TwinCAT HMI application using button on HMI

6 Posts
4 Users
4 Reactions
1,032 Views
MahmoodTalouzi
Posts: 2
Topic starter
(@mahmoodtalouzi)
Active Member
Joined: 2 years ago

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;

 

 

 

 

Reply
5 Replies
Posts: 9
(@unchained)
Active Member
Joined: 2 years ago

That is greatly helpful, thank you 🙂

Reply
Posts: 9
(@unchained)
Active Member
Joined: 2 years ago

Is there a solution for PLC HMI as well?

Reply
1 Reply
MahmoodTalouzi
(@mahmoodtalouzi)
Joined: 2 years ago

Active Member
Posts: 2

@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.

 

 

Reply
Posts: 1
(@flareux)
New Member
Joined: 2 years ago

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.

Reply
Posts: 1
(@osclar)
New Member
Joined: 2 years ago

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

Reply
Share: