javascript - Windows Script Host "cannot find file" exception in windows XP only -
code:
var regs = {'e':/[e]/g};//in real code here actual regular expressions var fso = new activexobject("scripting.filesystemobject"); var objshell = new activexobject("shell.application"); var lib, new_file; var cur_path = wscript.scriptfullname.substring(0, wscript.scriptfullname.length - wscript.scriptname.length); in_path = cur_path+'input'; out_path = cur_path+'output/'; lib = objshell.namespace(in_path); items = lib.items() n=0; (i=0;i<items.count;i++) { fitem = items.item(i); cur_file = fso.opentextfile(in_path + '/' + fitem.name, 1); new_file = fso.createtextfile(out_path + fitem.name, true); while (cur_file.atendofstream == false) { var line = cur_file.readline(); (key in regs) { line = line.replace(regs[key], key ); } new_file.writeline(line); } cur_file.close(); new_file.close(); n++; } wscript.echo("total files found/converted:" + + "/" + n);
the folder script contains input
, output
folders samples in input
folder.
i need work in winxp.
script works in win7, yet user claims in windows xp exception "file not found" (or similar) thrown , says "in line 22". 22nd line in script empty 1 between "cur_file=..." , "new_file=...".
can tell me what's wrong this? there difference between openastextstream
, opentextfile
methods xp (except caller)?
my guess has messed createtextfile
or opentextfile
method proper method name in winxp or different pathing in winxp or else. unfortunately have no winxp , can't test properly.
upd: noticed have missing semicolon in line 15. can reason such behaviour? (i doubt it)
try replacing slashes backslashes, example:
cur_file = fso.opentextfile(in_path + '\' + fitem.name, 1);
if works, win7 normalizes file paths automatically.
Comments
Post a Comment