es.exe is the command line interface to everything which, apart from DOpus, is my most frequently used application. Both of the following commands work correctly from a DOS window. Output is sent to the clipboard.
When executed from a script, the first command works but the second does not. I also tried triple quotes. Test code and corresponding output as shown below.
var objWShell = new ActiveXObject("WScript.Shell");
var str1 = '"C:\\Program Files\\everything\\es.exe" zipfs.jar';
var str2 = '"C:\\Program Files\\everything\\es.exe" path:"\\program files" zipfs.jar';
var str3 = '"""C:\\Program Files\\everything\\es.exe""" path:"""\\program files""" zipfs.jar';
var cmdstr1 = "cmd.exe /c "+str1+"|clip";
DOpus.output("cmdstr1 = " + cmdstr1);
var res = objWShell.Run(cmdstr1,0,true);
DOpus.output("res = " + res);
var cmdstr2 = "cmd.exe /c "+str2+"|clip";
DOpus.output("cmdstr2 = " + cmdstr2);
var res = objWShell.Run(cmdstr2,0,true);
DOpus.output("res = " + res);
var cmdstr3 = "cmd.exe /c "+str3+"|clip";
DOpus.output("cmdstr3 = " + cmdstr3);
var res = objWShell.Run(cmdstr3,0,true);
DOpus.output("res = " + res);
I appreciate that this is not a DOpus issue but I am hoping that someone knows how to wrangle the WScript.Shell command string to reproduce what works just fine in a DOS window.
Good suggestion. I had not tried with the cmd.exe /c prefix. Results demonstrate that the shell is okay with one quoted string but loses the plot when a second quoted string is introduced. I tried various combinations of single, double and triple quotes to no avail. The DOS shell handling of quoted strings appears to be a black art. I'll see if the likes of Stack Overflow has any insights.
My previous attempt incorrectly quoted "path:\program files" as a single string but path: is a keyword and "\program files" is the associated search string.