Need To Switch Shader Attribures

I have a scene with about 500 objects(and will increase).

I need to change texture, difuse and specular on several of them during animation. Rest of them must not change.(actually they will but later in time)
So i need to reconnect them to another SG that has theese attribures different (I cannot change just theese atributes because it will affect all objects but not a small group of them).

I made a script but it gives needed effect only in viewport, it dont render.

Any other solution will be good.(exept for replacing objects with other)

Please help me with this case.

Could just duplicate the objects, switch the shader, and key the visibility on/off as required?

more options:

you can animate shader connection changes by using layeredTextures or layeredShaders, just key the transparency from 1 to 0 in one frame. (if you get weird results with the layeredShader make sure you have the Compositing Flag set to Layer Texture) Also using ShadingSwitch nodes can be good if you don't want to duplicate your whole shading network for those specific objects.