-1

I am launching notepad.exe using javascript and passing parameters to it using following script. It launches notepad.exe but prompts that Hello World.txt does not exists. Do you want to create?

Any Idea/Suggestion to pass parameter and make notepad.exe written with Hello World

function passParam()
{
try{
    //get brwosers details
    var isIE = /*@cc_on!@*/false || !!document.documentMode;

    if(isIE == true)
    {
        var oShell = new ActiveXObject("Shell.Application");

        var filePath = "C:\\Windows";
        var fileName = "notepad.exe";
        var commandParms = "Hello World!";

        oShell.ShellExecute(fileName,commandParms,filePath,"open","1");

        return;
    }
    alert("Please use only IE to launch navigator.");   
}
catch(e){
alert("Error:"+e.message);}
}
AQ Dev
  • 43
  • 3
  • 14

1 Answers1

0

The command line argument of notepad.exe is a filename to open, not the initial contents of the notepad. You have to write a file to the disk and open notepad pointing to it.

Tamas Hegedus
  • 28,755
  • 12
  • 63
  • 97
  • Gotcha!! Is there any possibilities to pass arguments?? – AQ Dev Jul 08 '16 at 12:31
  • No, there is not. The only way is that I have written, creating a file and opening that. Or you could fill it after open with winapi like this: http://stackoverflow.com/questions/31021002/open-new-notepad-exe-and-write-content-to-it – Tamas Hegedus Jul 08 '16 at 12:44