I want to modify this photoshop .js script to save as a different format
I'm very new to photoshop scripting, so I appologize if this is such a newbie question, but my coding skills didn't take me very far unfortunately.
my goal is to have a script that saves as an Icon and close the document afterwards, photoshop doesn't support saving as Icon by default, but using This Plugin it gives me the option to do so (image has to be 8bit and no larger than 256x256) 
I found the script below in the form, it does most of what I want, except that it saves as png, I want to change that so it saves as an Icon.ico
main();
function main(){
if(!documents.length) return;
try{
var Path = decodeURI(activeDocument.path);
}catch(e){return;}
if(!Folder(Path).exists){
alert(Path + " Does not exist!");
return;
}
var Name = decodeURI(app.activeDocument.name).replace(/\.[^\.]+$/, '');
var saveFile = File(Path + "/" + Name + ".png");
sfwPNG24(saveFile);
//Uncomment the line below if you want to close the document.
//app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
function sfwPNG24(saveFile){
var pngOpts = new PNGSaveOptions;
pngOpts.compression = 9;
pngOpts.interlaced = false;
activeDocument.saveAs(saveFile, pngOpts, true, Extension.LOWERCASE);
and if possible, I want the script to also minimize photoshop after it's finished.
I should mention that after choosing to save as an icon, the plugin pops up this "Choose icon format" box (I always use standard ICO) so this has to be addressed in the script somehow
any help is appreciated, Thank you in advance.
