Luckily this seems not easy. Mechanical parts do not like being unmaintained for decades, while being stored in a damp/sandy/cold/hot environment. Batteries, solar cells and other means of stored energy are not to fond of that either.
A virus on the other hand that inserts itself for example into source code could very well live a long time.
A virus on the other hand that inserts itself for example into source code could very well live a long time.