PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, August 22, 2022

[FIXED] How can i pass environment params inline on windows cmd

 August 22, 2022     cmd, environment-variables, windows     No comments   

Issue

i need to run a script with node on windows like:

HOST=www.host.com node index.js

but this showme a error like "HOST" no se reconoce como un comando interno o externo*


*English Translation: "HOST" is not recognized as an internal or external command


Solution

What you want is to run both the set command to set your Host environment variable in the same line that you run your script with node. Running two commands one after an other is possible in the command line with the & and && operators.

From ss64

commandA &  commandB      Run commandA and then run commandB
commandA && commandB      Run commandA, if it succeeds then run commandB 

Here, since you likely don't want to continue to executing your node script if you are unable to set the environment variable, you would likely want to opt for the && operator for this use case.


Final Code:

set "HOST=www.host.com" && node index.js

Note:

SET in this context will never return an error. As such, both & and && are functionally identical for this use case.



Answered By - Spyre
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing