There is an example of how to do this in the AATK scripts. In \vbs\Route\, there are several ReplaceVia scripts. You can open one of them to see the full deal. I use ReplaceVias - thales-2007-Final.efm.
What it comes down to is
Set ViaPadstack = doc.PutPadstack(ReplaceViaSpanStart, ReplaceViaSpanEnd, NewViaName, False, False)
then
Set Via = doc.PutVia(pcbViaX, pcbViaY, ViaPadstack, doc.FindNet(pcbViaNet), Nothing, epcbAnchorNone, epcbUnitCurrent)
Of course there is a lot more surrounding these two lines. A lot of setup and getting all the right information such as location, net name, via span, and so on. Plus some error checking and DRC setup. The EFM I referenced above will show you all that.
Now if you want to change pin padstacks, the best thing to do is to not try to do that. Fix your library or make a new part or whatever. The hassle that will ensue if you try to do it is not worth it.