Hi all,
Newbie question - I want to create a script/executable to copy files from a subdirctory, and then update the copied ("local") versions with the current timestamp. The only way I could figure out the timestamp issue, was to actually write over the local copy's contents, then save it. See code at bottom of message. Now maybe there's a better way to do that - but that's not my question. (Note: code implies you have a subdirectory called "SubDir", and it contains a readable text file called "myfile.txt".)
I can compile the code (using jsc), and run the executable on my C drive and everything's fine. Now I move the whole directory/subdirectory tree somewhere else on my C drive, and everything's still fine 'cos all paths are relative. Now I move the whole thing to a networked drive H:, and suddenly no go - error message is:
Unhandled Exception: Microsoft.JScript.JScriptException: Can't create object
Can't create object
at Microsoft.JScript.ActiveXObjectConstructor.CreateInstance(Object[] args)
at JScript 0.CopyTextFile(Object this, VsaEngine vsa Engine, Object myfile)
at JScript 0.Global Code()
at JScript Main.Main(String[] )
So what am I doing wrong
// My code below
var f1="myfile.txt";
CopyTextFile(f1);
function CopyTextFile(myfile)
{
var fso, ts, s, tf;
fso = new ActiveXObject("Scripting.FileSystemObject");
ts = fso.OpenTextFile(".\\SubDir\\" + myfile);
s = ts.ReadLine();
ts.Close();
tf = fso.CreateTextFile(myfile, true);
tf.Write (s);
tf.Close();
}

Newbie: script runs on local but not networked drive??