Powershell 使用基于环境变量的路径运行脚本
我将环境变量Powershell 使用基于环境变量的路径运行脚本,powershell,syntax,environment-variables,Powershell,Syntax,Environment Variables,我将环境变量ARTEMIS\u HOME设置为c:\ARTEMIS PS C:\artemis_brokers> $env:ARTEMIS_HOME C:\artemis PS C:\artemis\u brokers>/$env:artemis\u HOME/bin/artemis ./$env:ARTEMIS_HOME/bin/ARTEMIS:The term./$env:ARTEMIS_HOME/bin/ARTEMIS' 无法识别为cmdlet、函数、脚本文件或脚本的名称 节目。检查名称的
ARTEMIS\u HOME
设置为c:\ARTEMIS
PS C:\artemis_brokers> $env:ARTEMIS_HOME
C:\artemis
PS C:\artemis\u brokers>/$env:artemis\u HOME/bin/artemis
./$env:ARTEMIS_HOME/bin/ARTEMIS:The term./$env:ARTEMIS_HOME/bin/ARTEMIS'
无法识别为cmdlet、函数、脚本文件或脚本的名称
节目。检查名称的拼写,或者如果包含路径,请验证
请确认路径正确,然后重试。
第1行字符:1
+./$env:ARTEMIS_HOME/bin/ARTEMIS
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo:ObjectNotFound:(../$env:ARTEMIS_HOME/bin/ARTEMIS:String)[],CommandNotFoundException
+FullyQualifiedErrorId:CommandNotFoundException
PS C:\artemis_brokers>/$env:artemis_HOME/bin/artemis.cmd
./$env:ARTEMIS_HOME/bin/ARTEMIS.cmd:术语'/$env:ARTEMIS_HOME/bin/
无法将artemis.cmd'识别为cmdlet、函数、脚本的名称
文件或可操作程序。检查名称的拼写,或者检查路径是否正确
已包括,请验证路径是否正确,然后重试。
第1行字符:1
+./$env:ARTEMIS_HOME/bin/ARTEMIS.cmd
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo:ObjectNotFound:(../$env:ARTEMIS_HOME/bin/ARTEMIS.cmd:String)[],CommandNotFoundException
+FullyQualifiedErrorId:CommandNotFoundException
PS C:\artemis\u brokers>/“$env:artemis\u HOME/bin/artemis.cmd”
./$env:ARTEMIS_HOME/bin/ARTEMIS.cmd:术语'/$env:ARTEMIS_HOME/bin/
无法将artemis.cmd'识别为cmdlet、函数、脚本的名称
文件或可操作程序。检查名称的拼写,或者检查路径是否正确
已包括,请验证路径是否正确,然后重试。
第1行字符:1
+./“$env:ARTEMIS_HOME/bin/ARTEMIS.cmd”
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo:ObjectNotFound:(../$env:ARTEMIS_HOME/bin/ARTEMIS.cmd:String)[],CommandNotFoundException
+FullyQualifiedErrorId:CommandNotFoundException
PS C:\artemis_brokers>\$env:artemis_HOME/bin/artemis
.\$env:ARTEMIS_HOME/bin/ARTEMIS:The term.\$env:ARTEMIS_HOME/bin/ARTEMIS'
无法识别为cmdlet、函数、脚本文件或脚本的名称
节目。检查名称的拼写,或者如果包含路径,请验证
请确认路径正确,然后重试。
第1行字符:1
+.\$env:ARTEMIS_HOME/bin/ARTEMIS
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo:ObjectNotFound:(.\$env:ARTEMIS\u HOME/bin/ARTEMIS:String)[],CommandNotFoundException
+FullyQualifiedErrorId:CommandNotFoundException
PS C:\artemis_brokers>\$env:artemis_HOME/bin/artemis.cmd
.\$env:ARTEMIS\u HOME/bin/ARTEMIS.cmd:术语“\$env:ARTEMIS\u HOME/bin”/
无法将artemis.cmd'识别为cmdlet、函数、脚本的名称
文件或可操作程序。检查名称的拼写,或者检查路径是否正确
已包括,请验证路径是否正确,然后重试。
第1行字符:1
+.\$env:ARTEMIS_HOME/bin/ARTEMIS.cmd
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo:ObjectNotFound:(.\$env:ARTEMIS\u HOME/bin/ARTEMIS.cmd:String)[],CommandNotFoundException
+FullyQualifiedErrorId:CommandNotFoundException
PS C:\artemis_brokers>“$env:artemis_HOME/bin/artemis.cmd”
.\$env:ARTEMIS\u HOME/bin/ARTEMIS.cmd:术语“\$env:ARTEMIS\u HOME/bin”/
无法将artemis.cmd'识别为cmdlet、函数、脚本的名称
文件或可操作程序。检查名称的拼写,或者检查路径是否正确
已包括,请验证路径是否正确,然后重试。
第1行字符:1
+.\“$env:ARTEMIS\u HOME/bin/ARTEMIS.cmd”
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo:ObjectNotFound:(.\$env:ARTEMIS\u HOME/bin/ARTEMIS.cmd:String)[],CommandNotFoundException
+FullyQualifiedErrorId:CommandNotFoundException
在尝试执行之前,需要展开变量并将路径的其余部分连接成字符串。要执行结果字符串,请使用
和,:
尝试:
只需执行cmd.exe/c“$env:ARTEMIS\u HOME\bin\ARTEMIS.cmd”
PS C:\artemis_brokers> $env:ARTEMIS_HOME/bin/artemis
At line:1 char:19
+ $env:ARTEMIS_HOME/bin/artemis
+ ~
You must provide a value expression following the '/' operator.
At line:1 char:19
+ $env:ARTEMIS_HOME/bin/artemis
+ ~~~~~~~~~~~
Unexpected token 'bin/artemis' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedValueExpression
PS C:\artemis_brokers> ./$env:ARTEMIS_HOME/bin/artemis
./$env:ARTEMIS_HOME/bin/artemis : The term './$env:ARTEMIS_HOME/bin/artemis'
is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:1
+ ./$env:ARTEMIS_HOME/bin/artemis
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (./$env:ARTEMIS_HOME/bin/artemis:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\artemis_brokers> ./$env:ARTEMIS_HOME/bin/artemis.cmd
./$env:ARTEMIS_HOME/bin/artemis.cmd : The term './$env:ARTEMIS_HOME/bin/
artemis.cmd' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
+ ./$env:ARTEMIS_HOME/bin/artemis.cmd
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (./$env:ARTEMIS_HOME/bin/artemis.cmd:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\artemis_brokers> ./"$env:ARTEMIS_HOME/bin/artemis.cmd"
./$env:ARTEMIS_HOME/bin/artemis.cmd : The term './$env:ARTEMIS_HOME/bin/
artemis.cmd' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
+ ./"$env:ARTEMIS_HOME/bin/artemis.cmd"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (./$env:ARTEMIS_HOME/bin/artemis.cmd:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\artemis_brokers> .\$env:ARTEMIS_HOME/bin/artemis
.\$env:ARTEMIS_HOME/bin/artemis : The term '.\$env:ARTEMIS_HOME/bin/artemis'
is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:1
+ .\$env:ARTEMIS_HOME/bin/artemis
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (.\$env:ARTEMIS_HOME/bin/artemis:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\artemis_brokers> .\$env:ARTEMIS_HOME/bin/artemis.cmd
.\$env:ARTEMIS_HOME/bin/artemis.cmd : The term '.\$env:ARTEMIS_HOME/bin/
artemis.cmd' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
+ .\$env:ARTEMIS_HOME/bin/artemis.cmd
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (.\$env:ARTEMIS_HOME/bin/artemis.cmd:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\artemis_brokers> .\"$env:ARTEMIS_HOME/bin/artemis.cmd"
.\$env:ARTEMIS_HOME/bin/artemis.cmd : The term '.\$env:ARTEMIS_HOME/bin/
artemis.cmd' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
+ .\"$env:ARTEMIS_HOME/bin/artemis.cmd"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (.\$env:ARTEMIS_HOME/bin/artemis.cmd:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
& "$env:ARTEMIS_HOME/bin/artemis.cmd"
& $env:ARTEMIS_HOME\bin\artemis.cmd