All Questions
Tagged with command-line environment-variables
224
questions
0
votes
2
answers
1k
views
How to safely store environmental variables and make it actually invisible in my PC?
I am learning about environmental variables. I know for example that if I have a secret password I should not code it inside of my code.
From what I understood is that a .env file should be used to ...
0
votes
0
answers
47
views
Windows cmd won't recognize changed PATH
Few days ago I installed Tesseract OCR by installing Capture2Text via Chocolatey. This proved not to work, and instead of uninstalling Capture2Text I went ahead and deleted the Capture2Text folder ...
1
vote
1
answer
359
views
Node wont run from cmd unless the .exe extension is added
So this is a very weird one. Let me start by saying that things used to work fine.
I installed Node a few days ago and once complete I opened a command prompt (On Windows 10), I entered node --version ...
-2
votes
2
answers
287
views
How to use CD command in Windows Terminal with custom environment variables?
If I create a environment variable, I can use it with Win+R and enter %MyVariable%. The directory opens in Windows Explorer.
However, if I try to do the following using Windows Terminal
cd %MyVariable%...
0
votes
2
answers
227
views
BATCH: Correctly interpret environment variables passed by user through set /p
I want to support variable comprehension from user input in my script.
>set target=%programdata%
>echo %target%
Gives me:
C:\ProgramData
All well and good, however...
>set /p target=
>%...
1
vote
1
answer
548
views
Expand variable to alias and execute
I have an alias set in my .bash_aliases file to execute neovim.
I can successfully use this alias from the command line however I cannot use this alias via a variable (ie the EDITOR variable - set in ....
2
votes
0
answers
134
views
Running android avdmanager with sudo
I am running avdmanager create avd from my python script that I start with sudo -E to make my script be able to do priveldged stuff. But for some reason avdmanager created AVD inside /root/.android/...
0
votes
2
answers
1k
views
How do I pass an argument from Windows Batch to single Powershell Command?
I know I can pass variables to a powershell script like this: powershell -file ".\filetorun.ps1" "arg1" "arg2" and put param(var1=args[0],var2=args[1]) in the Powershell ...
0
votes
0
answers
42
views
What happened to this added directory in environment variables path?
Added the following directory to the path by using this method:
set path=%path%;D:\Programm\jflex-1.8.2\jflex-1.8.2\bin
set path=%path%;D:\Programm\jflex-1.8.2\jflex-1.8.2\bin\jflex
but, I can't find ...
0
votes
1
answer
207
views
Why do environment variables only expand to a certain level of nesting?
I found some confusing behavior in working with environment variables. If I have two environment variables and one points to another, when I reference the pointer variable, it will be automatically ...
0
votes
2
answers
4k
views
Setting environment variables in bash script doesn't work?
If I run this on the command line, it will make the commit be at the specified date:
THE_TIME='2022-01-01T22:50:12 -0700' GIT_AUTHOR_DATE=$THE_TIME GIT_COMMITTER_DATE=$THE_TIME git commit -am 'commit'
...
0
votes
1
answer
694
views
How to expand a variable containing another variable in a Windows Command Prompt window?
I have a variable x with the value "%USERPROFILE%\Downloads". In other words, the command set x produces the output shown below.
x="%USERPROFILE%\Downloads"
I then entered the ...
3
votes
1
answer
604
views
ts - timestamp input utility: setting time zone for time stamps
Under the ENVIRONMENT section man page for ts [ts(1)] reads:
The standard TZ environment variable controls what time zone dates are
assumed to be in, if a timezone is not specified as part of the ...
0
votes
0
answers
384
views
How to use environment variables to fix the error caused by having a space in username when running a command?
I'm trying to run
yarn create strapi-app --quickstart
but I get
C:\Users\user' is not recognized as an internal or external command operable program or batch file.
since my username has a space in ...
2
votes
1
answer
726
views
How can I make CMD load normal system commands by default? (command prompt / powershell)
Please see below screenshot, this is pretty much self explanatory. All default programs in System32 aren't being loaded and can't run unless I specify the exact directory and path of the program
...
0
votes
1
answer
3k
views
How to store the result of a subquery in a variable in cmd?
Here's my bat file:
@echo off
for /F "tokens=* delims=," %%a in ('type C:\LocalSecrets\Depolyment.csv ^| findstr "%DomainName%"') do call :parcsv %%a
goto :EOF
:parcsv
echo &...
3
votes
1
answer
9k
views
Setting user PATH environment variable on Windows 10 has no effect
I have a bizarre problem with setting my user PATH variable. C:\Program Files\ghcup\bin is the path to my executable that I want to add to my user PATH.
I have tried setx /M path "%PATH%;C:\...
1
vote
1
answer
676
views
How to echo environment variable in variable in DOS
I am not sure if this question holds true but I am trying to get solution for my problem as below:
set var1=ABC
set otherevars=C:\temp2
set %var1%dfts=C:\temp\test
all works fine till above line but, ...
1
vote
0
answers
17
views
What does the start command actually do? [duplicate]
Suppose I want to launch a program from the cmd (or windows powershell). If i simply type the name of the executable of course nothing starts, as my shell does not know where to find the .exe that I ...
1
vote
3
answers
58
views
Can i convert my code in a global enviroment variable?
I made this code to be able to easily move a directory between my SSD and HD and also output a timestamp in my robocopy log files easily, it worked so well that i want to turn my timestamp &z& ...
0
votes
0
answers
1k
views
Typing echo %path% in cmd shows a path that I don't see on the edit environment variables menu
I have this path to Miniconda C:\Users\[username]\miniconda3\condabin that shows up as the first entry when I type echo %path% in my cmd.exe but upon trying to edit it through the system environment ...
-1
votes
3
answers
12k
views
How to get existing environment variable, change the value of it and display it after change with CMD command?
So, after discussing with Berend, I figured out that I need to explain myself better and that is what I'm going to do.
So, my mission is to write a windows batch script that will:
Display(print to ...
0
votes
2
answers
5k
views
How to call programs from cmd directly without adding their paths to PATH variable on windows?
Suppose I installed a new package with someProgram in it:
myNewPackageDir/bin/someProgram
If I want to accessing it from cmd using only its name (example: someProgram --option1 a --option2 b --option3 ...
1
vote
1
answer
610
views
Docker get a list of possible environment variables
Hello! After intensive research I decided to bring this question up to the community. I started learning docker & docker-compose not long ago.
My question is:
How can I get a list of the possible ...
1
vote
1
answer
971
views
Windows Command Line Batch Variable Substring with WMIC Output not Truncating Properly
Using Windows Batch all I want to do is get the specified drive size in MB (by drive letter) and corresponding free space available for that drive stored in a variable as an integer to do some basic ...
2
votes
2
answers
171
views
Why are there two standards for accessing environment variables in Windows when they call point to the same environment variables?
I can use $env:<env-name> in Powershell to access an environment variable, and in cmd and all other parts of Windows I can use %env-name% to access them.
Why is are there two different standards ...
1
vote
1
answer
8k
views
How to setup environment variable for MSVC in Windows like GCC?
In GCC, I just need to set the MinGW/bin path to use it from the command line... But how to use MSVC from the command line? I don't want to create a project folder. In GCC, I don't need to specify/...
2
votes
0
answers
892
views
Powershell can't see "git" or "node" commands while cmd can
Using Windows 10, I can't run certain commands from PowerShell but they all work correctly using cmd.
PowerShell:
node --version:
node : The term 'node' is not recognized as the name of a cmdlet, ...
2
votes
3
answers
2k
views
How to add a single executable from a certain directory to PATH environmental variable?
I was looking for a way to add only one specific executable file from a certain directory to the PATH environmental variable. Instead of adding the whole directory C:\Program Files\Firefox Beta I ...
0
votes
1
answer
310
views
SOLVED: why does my windows 10 user path show fully duplicated values from system path?
My windows 10 user path variable only has the entry %USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\bin
I have put all other path settings into the system path variable.
If I open a command ...
0
votes
1
answer
3k
views
How to use environment variables in a powershell pipeline?
The command
systeminfo | find "System Type"
is supposed to return
System Type: x64-based PC
both in a Command Prompt window and in PowerShell.
In my case it says
/usr/bin/...
4
votes
2
answers
990
views
PATHEXT environment variable not working
I want to use gcc on Windows, so someone gave me a MinGW folder. I put the D:\software\MinGW\bin\ folder in my PATH. But when I open a new CMD and type gcc, I get
'gcc' is not recognized as an ...
0
votes
1
answer
378
views
`wsl env` gives different result to `wsl` followed by `env`
Inside WSL (i.e. by opening a cmd and then running wsl, or just running wsl straight from the start menu) I have this line at the end of ~/.bashrc:
LANG=en_US.UTF-8
While still inside WSL, if I do ...
1
vote
1
answer
3k
views
how do I run a sudo command and load the environment variables of current logged on user?
I need to run an ssh sudo command.
command is as follows:
ssh -i keyfile [email protected] 'sh -v /opt/dir/script'
the script contains the following:
sudo -E node some.js
the reason I use the -E ...
0
votes
4
answers
23k
views
"Python" working but "Py" is not
I'm on Windows 10 and have Python 3.9.0 installed. The evinronment variables I have for Python are C:\Users\Zimplfy\AppData\Local\Programs\Python\Python39\ and C:\Users\Zimplfy\AppData\Local\Programs\...
0
votes
2
answers
23k
views
How do I add Environment Variables of Chrome in Windows 10?
For my class assignment I need to add Google Chrome to Environment Variables. I tried to go there, click on edit in the Path variable, click on new and add this: %chrome%C:\Program Files\Chrome\...
5
votes
3
answers
12k
views
Can not start Chrome via command line
I have a script that needs to run on multiple machines.
The problem is, if I open a command line and type in chrome or chrome.exe, I get the same error message that it is not recognized as an internal ...
0
votes
1
answer
273
views
Why clearing PATH in windows CMD prompt makes it close immediatly?
Consider these 2 versions of a cmd script.
First Version (overrides PATH)
set PATH=%USERPROFILE%.cargo\bin;%USERPROFILE%.rustup;
%~d1
cd "%~p1"
call cmd
Second Version (add some path to ...
1
vote
2
answers
5k
views
Python refuses to be recognized in Command Prompt despite multiple attempts to add to PATH
I've downloaded and uninstalled Python so many times trying to get this to work. No matter what happens I always get:
"'python' is not recognized as an internal or external command, operable ...
0
votes
1
answer
3k
views
Windows Batch Script and handling file names with "!" Exclamation point in For Loop
Part of my script I am having issue with is here:
setlocal enabledelayedexpansion
for /r %%a in (*) do (
cd "%%~dpa"
set /A count += 1
set fn=file!count!
%batchdir%\7z.exe a -mx9 -sdel -p"%password%"...
2
votes
0
answers
219
views
Python and Perl not recognized in cmd even after adding in environment
It was fine yesterday, but it suddenly stopped working today.
Both my perl and python were not recognized in cmd. I read as much as i can online for the answers and follow the instruction. I have ...
1
vote
0
answers
7k
views
stderr: 'chcp' is not recognized as an internal or external command, operable program or batch file
I'm trying to install required dependencies for Intel's DC to edge course. While creating the environment by
C:\Geth\DC to Edge Course\Notebooks>conda env create -f environment.yml
Collecting ...
0
votes
1
answer
783
views
Adding executable files to my PATH in a Linux shell
My goal is to run the R file helloworld.r from my home directory using Rscript in a Linux shell. My helloworld.r file looks like this
#!/home/usr/env Rscript
print("Hello World")
I have added export ...
1
vote
1
answer
2k
views
Expand Environment Variables in string and store the result in another variable
This may sound a bit silly, as I am not a regular Batch script programmer.
How do I expand any Environment Variable inside a string and store the final expanded output into another variable, means ...
2
votes
1
answer
2k
views
How to create custom Global System-wide variables like $Home in Powershell and assign persistent value to it?
I am just starting to learn Powershell and already one thing started bugging me.
The undesirably & unfairly confusing discrimination between $env:Home and $HOME. Where $HOME can be autocompleted ...
1
vote
1
answer
4k
views
Command Line Windows: How can I set a global variable within a call?
I want to change a counter variable within a call function.
In my example I want to count all subfolders (= count_all) and afterwards I want to increment the count of the subfolders it successfully ...
0
votes
1
answer
390
views
WIN10 Environment path variables not recognized when opening terminal from background context
I installed Java RE and Git, for example, and made sure their binaries were added to Environment Path Variables under both User and System variables. When I launch a command prompt from the taskbar, ...
19
votes
2
answers
4k
views
Why doesn't CMD inherit environment variables on this machine?
For whatever reason, on a specific machine my cmd process doesn't inherit its environment variables from the parent process which launched it. Instead it reverts back to the "default" environment ...
1
vote
1
answer
5k
views
Returning values Batch files that CALL functions with SETLOCAL set
SETLOCAL ... ENDLOCAL innoculate local variables so completely that Functions which try to compute values and return them fail.
Typically, these are functions that parse files and strings with for-do ...
2
votes
2
answers
7k
views
Does copy command not accept variable on command line?
How can I use a variable in batch file for copy command to provide path for root folder?
set destination= "c:\destination folder"
mkdir %destination%
SET source = "C:\source folder\"
SET source_full ...