Exit WinCC and logout/restart/shutdown PC

Find and share HowTos to various installations / configurations!
2 posts • Page 1 of 1
Kirvesmies
Posts:42
Joined: Mon Dec 04, 2017 2:28 pm

Exit WinCC and logout/restart/shutdown PC

Post by Kirvesmies »

How can this be scripted to a button in WinCC? Both Win & Linux Centos gnome

if(_UNIX) ...
else...

mkoller
Posts:741
Joined: Fri Sep 17, 2010 9:03 am

Re: Exit WinCC and logout/restart/shutdown PC

Post by mkoller »

On Linux/Gnome you should be able to logout as follows:

Code: Select all

system("loginctl terminate-session " + getenv("XDG_SESSION_ID"));
For restart the whole PC (wyh would you need that?):

Code: Select all

system("sudo /sbin/reboot");
For shutdown:

Code: Select all

system("sudo /sbin/halt");
Reboot/Shutdown needs the privileges for the user to do so. check "man sudo"

2 posts • Page 1 of 1