Home > Enterprise >  How to run path setting script in vscode terminal at startup?
How to run path setting script in vscode terminal at startup?

Time:05-12

I have a script which sets path variables. I have to run this script manually every time I start a new terminal instance.

I am looking for an automated way to run this script at startup for every terminal instance.

I have tried the below approach which doesn't work

{
  "terminal.integrated.profiles.windows": {
    "Command Prompt": {
      "path": "cmd.exe",
      "args": [
         "-noexit",
         "-file",
         "h:\\all-languages-env.cmd"
      ]
    }
  },
  "terminal.integrated.defaultProfile.windows": "Command Prompt",
}

I am expecting the script h:\all-languages-env.cmd to run at every terminal(Command Prompt) startup.

The script file is as below

@ECHO OFF
call devtools isSupported nodejs 16.13.0 || exit /B %ERRORLEVEL%
call devtools isSupported phantomjs 2.1.1 || exit /B %ERRORLEVEL%
set npm_config_registry=http://example.com
set npm_config_user_agent="npm/{npm-version} node/{node-version} {platform} {arch} | NDS %USERNAME% %COMPUTERNAME%"
set SASS_BINARY_SITE=http://example.com/node-sass
set SPAWN_WRAP_SHIM_ROOT=H:\.nodejs
set CHROME_BIN="C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
set npm_config_prefix=H:\.nodejs\npm\8
set npm_config_cache=H:\.nodejs\npm\8\cache
set npm_config_tmp=H:\.nodejs\npm\8\tmp
set NODEJS_16_13_0=H:\nodejs\16
set PATH=%NODEJS_16_13_0%;H:\.nodejs\npm\8;%PATH%
type nul > H:\nodejs\16\lastUsed
set PHANTOMJS_2_1_1=H:\phantomjs\2\bin
set PHANTOMJS_BIN=%PHANTOMJS_2_1_1%\phantomjs.exe
set PATH=%PHANTOMJS_2_1_1%;%PATH%
type nul > H:\phantomjs\2\lastUsed
ECHO javascript environment set

CodePudding user response:

cmd.exe uses different arguments

{
  "terminal.integrated.profiles.windows": {
    "Command Prompt": {
      "path": "cmd.exe",
      "args": [
         "/K",
         "h:\\all-languages-env.cmd"
      ]
    }
  },
  "terminal.integrated.defaultProfile.windows": "Command Prompt",
}
  • Related