Windows 等效于 $export

我正在尝试按照一些说明使用命令行创建一个目录。这些说明是:

$ export PROJ_HOME=$HOME/proj/111
$ export PROJECT_BASEDIR=PROJ_HOME/exercises/ex1
$ mkdir -p $PROJ_HOME

这些是窗口命令吗? 有窗口等价物吗?

223059 次浏览

To translate your *nix style command script to windows/command batch style it would go like this:

SET PROJ_HOME=%USERPROFILE%/proj/111
SET PROJECT_BASEDIR=%PROJ_HOME%/exercises/ex1
mkdir "%PROJ_HOME%"

mkdir on windows doens't have a -p parameter : from the MKDIR /? help:

MKDIR creates any intermediate directories in the path, if needed.

which basically is what mkdir -p (or --parents for purists) on *nix does, as taken from the man guide

There is not an equivalent statement for export in Windows Command Prompt. In Windows the environment is copied so when you exit from the session (from a called command prompt or from an executable that set a variable) the variable in Windows get lost. You can set it in user registry or in machine registry via setx but you won't see it if you not start a new command prompt.

you can use export if you have git-bash installed.

Windows 10+, it is preserved for an user forever, run as admin for global var

setx myvariable myvariablevalue