i just had the same issue and found a solution that works for me in photoshop cs 5.1 (i think this will also work in cs 5). Although this thread is very old maybe somebody is interested in my solution:
I replaced the code in the function s4wPNG like this:
var pngSaveOptions = new PNGSaveOptions();
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var Ext = decodeURI(app.activeDocument.name).replace(/^.*\./,'');
var saveFile = File(directorypath + Name +".png");
activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
Hope this is helpful.