boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
DotNet版 - Powershell dot sourcing question.
相关主题
.Text 简易安装
问个c#的抓数据方面的问题
C#中调用JavaScript的问题
Anyone uses Script#?
访问MITBBS.com的问题
move to another swf file from Flex MXML script (转载)
[合集] asp 打开oracle数据库问题。
痛苦IT大妈求助
到底FluentMigrator有什么优点?
C#编程求助, 500伪币酬谢, 在线等
相关话题的讨论汇总
话题: path话题: powershell话题: put话题: sourcing话题: dot
进入DotNet版参与讨论
1 (共1页)
M7
发帖数: 219
1
I have two scripts, A.ps1 is the main function and B.ps1 has all the
functions that A.ps1 calls. Both scripts are in the same folder.
To put B into A’s scope, I tried to put the following in A.ps1
. .\B.ps1
With the above statement, or I put the path in single or double quotes, I
always get this error message:
The term '.\B.ps1' 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.
If I use the absolute path, the script runs smoothly.
. C:\Users\xyz\Desktop\B.ps1
Any clue what is wrong?
Thanks a lot!
t*****s
发帖数: 124
2
解决依赖问题在PowerShell 2.0里可以用Module
可参考 http://msdn.microsoft.com/en-us/library/dd878310(v=vs.85).aspx
如果非要用dot source的话,在A.ps1里加入
$myPath = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
. $myPath/relativePathToB/B.ps1

【在 M7 的大作中提到】
: I have two scripts, A.ps1 is the main function and B.ps1 has all the
: functions that A.ps1 calls. Both scripts are in the same folder.
: To put B into A’s scope, I tried to put the following in A.ps1
: . .\B.ps1
: With the above statement, or I put the path in single or double quotes, I
: always get this error message:
: The term '.\B.ps1' 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.
: If I use the absolute path, the script runs smoothly.

1 (共1页)
进入DotNet版参与讨论
相关主题
C#编程求助, 500伪币酬谢, 在线等
c#l developer position
Question: "-" operators: z= -x; z = x-y
Looking For Developers for PowerShell Remoting
Solution suggestions? (转载)
NuGet到底有多少用处?
azure一问
VS.net 有没有spelling checker?
混合语言编程
help: 又没有现成的.NET 网站的source code? (转载)
相关话题的讨论汇总
话题: path话题: powershell话题: put话题: sourcing话题: dot