Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set working directory in javascript

Does anyone know how to set the working directory in JavaScript before?

Code I use for launching an application is this:

// Create an object script
oL = new ActiveXObject("WScript.Shell");
oFile = '"C:/Application.exe"';
oL.run(oFile);
like image 422
williamtroup Avatar asked Mar 26 '26 03:03

williamtroup


1 Answers

According to MSDN, you should be able to use:

var oL = new ActiveXObject("WScript.Shell");
oL.CurrentDirectory = "C:\\Foo\\Bar";
oFile = '"C:\\Application.exe"';
oL.run(oFile);

...assuming you're running this script in Windows Script Host, in which case you probably ought to make that clear in your question - about 99% of JavaScript programmers only ever use the language in a web browser, where this kind of stuff is only possible under extremely unusual circumstances.

like image 100
NickFitz Avatar answered Mar 28 '26 15:03

NickFitz