if i press a button the command wil go only for 5 sec
You do not mention how you intend to use your button, but perhaps you can use the SequentialWrite function.
In the attached picture, you have an example (Properties window), where I use a pushbutton to set a controller variable (DummyBool), and then reset the same variable 3s later. Look at the properties "ExtendedWrite" and "Target".
I would however not recommend this solution for process control in any form. It is better to just set the variable, and then let the controller handle the timing and reset.
It all depends on what you want to achieve.
Your Windows operator station is not a real time OS and the timing of any command cannot be guaranteed. Neither can the performance and delays of the OPC communication system. Your 5 second timer could easily vary by a significant amount. And OPC does not work like this anyway.
OPC Write operations are "one-shot". When you do ANY opc write operation, the value is written to the PLC or controller only ONCE. If you want a 5 second pulse inside the controller, then use logic inside the controller to read your button, start a timer and reset the button after 5 seconds.
(But MyMe's solution would work if you absolutely must do this)