Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
82
rated 0 times [  88] [ 6]  / answers: 1 / hits: 6557  / 11 Years ago, sun, january 26, 2014, 12:00:00

I would like to run an executable and its path contains an enviroment variable, for example if I would like to run chrome.exe I would like to write something like this



var spawn = require('child_process').spawn;
spawn('chrome',[], {cwd: '%LOCALAPPDATA%\Google\Chrome\Application', env: process.env})


instead of



var spawn = require('child_process').spawn;
spawn('chrome',[], {cwd: 'C:\Usersmyuser\AppData\Local\Google\Chrome\Application', env: process.env}).


Is there a package I can use in order to achieve this?


More From » node.js

 Answers
11

These answers are crazy. Just can use path:


const folder = require('path').join(
process.env.LOCALAPPDATA,
'Google/Chrome/Application',
);

console.log(folder); // C:UsersMyNameAppDataLocalGoogleChromeApplication

[#48343] Friday, January 24, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
naomim

Total Points: 344
Total Questions: 95
Total Answers: 114

Location: Wales
Member since Mon, May 17, 2021
3 Years ago
;