1

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");
        }
M. Ali
  • 37
  • 6
  • 1
    Please remove duplicate flag, as NPAPI was allowing to access local profile, and Chrome just stop supporting NPAPI, Now they are allowing to use, https://developer.chrome.com/apps/app_storage. . .so please remove duplicate flag – M. Ali Feb 27 '17 at 16:11
  • You actually can't remove flags, but a mod will see your comment. Do you care if the solution works in both browsers, or is only 1 good enough? – msanford Feb 27 '17 at 16:54
  • I need to work it in both browsers or atleast in Chrome. – M. Ali Feb 27 '17 at 17:10
  • Possible duplicate of [Launch application from a browser](http://stackoverflow.com/questions/3057576/launch-application-from-a-browser) – RoadieRich Feb 27 '17 at 19:04

1 Answers1

0

Build a custom link,like

tencent://Message/?*****&websiteName=qzone.qq.com&Menu=yes

When u click the link,a QQ client would be started

maiduo
  • 11
  • 1