if (window.ActiveXObject) { try { var fso = new ActiveXObject("Scripting.FileSystemObject"); fso.CopyFile("C:\Program Files\GM4IE\scripts\source.txt","C:\Program Files\GM4IE\scripts\target.txt", 1); fso = null; } catch (e) { alert (e.message); } }
I am getting error :
"Automation server can not create object" on the line where I am creating ActiveXObject instance.
I understand that it's considered very bad to access hard-drive data using javascript but I just need it.
I am using IE8 , Greasemonkey4IE to run my javascript.
Thank you,
Mohit
******************************
function WriteFile() { var fso = new ActiveXObject("Scripting.FileSystemObject"); fso.CopyFile("C:\source.txt","C:\target.txt", 1); }
I've put the above code inside a simple HTML page and it worked perfect.
http://www.c-point.com/JavaScript/articles/file_access_with_JavaScript.htm
You can find the similar code on above mentioned location.
I modified it a bit, tough.
But when I am trying to run it through GreaseMonkey4IE it simply spitting the same error I specified earlier.
I did it guys, but thanks a lot for your quick and helpful replies.
All I did is :
Go to Tools > Internet options > Security > Custom Level
Under the ActiveX controls and plug-ins, select Enable for Initializing and Script ActiveX controls not marked as safe.