相当于 $export 的 Windows
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18701783/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Windows equivalent of $export
提问by user1154644
I am trying to follow some instructions for creating a directory using the command line. The instructions are:
我正在尝试按照一些说明使用命令行创建目录。指令是:
$ export PROJ_HOME=$HOME/proj/111
$ export PROJECT_BASEDIR=PROJ_HOME/exercises/ex1
$ mkdir -p $PROJ_HOME
Are these windows commands? Are there windows equivalents?
这些是windows命令吗?有窗户等价物吗?
回答by rene
To translate your *nix style command script to windows/command batch style it would go like this:
要将您的 *nix 样式命令脚本转换为 windows/command 批处理样式,它将如下所示:
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:
Windows 上的 mkdir 没有 -p 参数:来自 MKDIR /? 帮助:
MKDIR creates any intermediate directories in the path, if needed.
如果需要,MKDIR 在路径中创建任何中间目录。
which basically is what mkdir -p (or --parents for purists) on *nix does, as taken from the man guide
这基本上是 *nix 上的 mkdir -p(或纯粹主义者的 --parents)所做的,如从 man 指南中获取的
回答by bubi
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.
Windows 命令提示符中没有用于导出的等效语句。在 Windows 中,环境被复制,因此当您退出会话(从调用的命令提示符或从设置变量的可执行文件)时,Windows 中的变量会丢失。您可以通过 setx 在用户注册表或机器注册表中设置它,但如果您不启动新的命令提示符,则不会看到它。