0

Trying to write a windows speech recognition macro. Written using XML and scripting language is JScript. Using ActiveXObject("WScript.Shell"), executables can be, well, executed. But how can we pass an argument to this executable ? Like, if I were to open IE using the above, how can I pass an argument so that it loads with a specified URL(argument) ?

In XML, we could write :

<run command = "C:\Program Files\BlahBlah\MusicPlayer.exe" params = "D:\Music\Music1.mp3"/>

How to do this in JScript ? Or VBScript? Any help appreciated. :)

2
  • It's a long time ago, but if I'm correct, you can supply parameters in a space-separated list. Eg: var ws = ActiveXObject("WScript.Shell");ws.Run('"C:\Program Files\BlahBlah\MusicPlayer.exe" "D:\Music\Music1.mp3"'); Commented Oct 29, 2011 at 19:51
  • WScript.Shell reference Commented Oct 30, 2011 at 13:27

2 Answers 2

1
<script language="javascript">
    function RunEXE( exeApp, para ) {
        var oShell = new ActiveXObject("WScript.Shell");
        oShell.Run( "\"" + exeApp + "\"" + "\"" + para + "\"", 1 );
    }

    RunEXE ( "D:\\ProgFiles\\player.exe", "D:\\My Music\\ music.mp3" )
</script>
Sign up to request clarification or add additional context in comments.

Comments

0

I was able to run this from JS. I created a console application which accepts an argument and invoked it from web application.

<script language="javascript" type="text/javascript">
    function RunEXE() {
        var oShell = new ActiveXObject("WScript.Shell");

        var prog = "D:\\FetchParam.exe";
        oShell.Run('"' + prog + '" INITParam', 1);
    }
</script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.