As Chrome/Firefox don't uses the Activex Objects and even don't allow to access using local profile (such as AppData\Roaming) due to security issues. But in one of my client request, I needed to create a .txt file and then to launch .exe from the aforementioned directory. Chrome before 2014 was supporting NPAPI that actually works well with the client side but in 2014 they also stop supporting NPAPI and it also marked as Phased on Chrome. So I need the latest technology that actually want needed to create a text file and then launch exe file from roaming folder.
Is there any option or client side api to perform this action?
Update
I've following snippet in ActiveXObject (Old approach) now I want to translate it into latest technology so that it could also be used by non-IE browsers as well.
function createLoginFile(){
var isIE = /*@cc_on!@*/false || !!document.documentMode;
if(isIE == true)
{ var wsShell = new ActiveXObject("wscript.shell");
var roamingAppData = wsShell.ExpandEnvironmentStrings("%appdata%");
var fileObj = new ActiveXObject("Scripting.FileSystemObject");
var folderObj = new ActiveXObject("Scripting.FileSystemObject");
var folderLoc = roamingAppData+"\\Navigator";
var fileLoc = folderLoc + "\\NavigatorLogin.txt";
if(fileObj.FileExists(fileLoc)){
//empty file
var emptyFile = fileObj.OpenTextFile(fileLoc, 2, false);
emptyFile.close();
//write to file
var openFile = fileObj.OpenTextFile(fileLoc, 2, false);
openFile.WriteLine("Hello World!");
openFile.close();
loadExe(folderLoc)
}
else{
var newfile = fileObj.CreateTextFile(fileLoc,false);
//write to file
newfile.WriteLine("Hello World");
openFile.close();
loadExe(folderLoc)
}
}
}
function loadExe(folderLoc){
var oShell = new ActiveXObject("Shell.Application");
var filePath = folderLoc+"\\Navigator.exe";
oShell.ShellExecute(filePath,"","","open","1");
}