murray Posted March 14, 2007 Report Share Posted March 14, 2007 If i execute c:\scritps\project\script.ps1 (when I'm standing in c:\) and the first line in that script is .\config.ps1 it wont work since config.ps1 is located in c:\scritps\project Therefore I want to do a "pwd" for the script.ps1 execution dir... How to?! Quote Link to comment Share on other sites More sharing options...
marco.shaw Posted March 14, 2007 Report Share Posted March 14, 2007 A few things you can do: 1. Add c:\scritps\project to your path, then you can just call "config.ps1", instead of ".\config.ps1" or other. 2. Hardcode c:\scritps\project\config.ps1 in your original script. Quote Link to comment Share on other sites More sharing options...
SilverTech Posted March 14, 2007 Report Share Posted March 14, 2007 I know what you want: Split-Path -Path $MyInvocation.MyCommand.Definition -Parent then if u run c:\test\script.ps1 from c:\ the output will be c:\test Quote Link to comment Share on other sites More sharing options...
murray Posted March 14, 2007 Author Report Share Posted March 14, 2007 Thanks! Works flawlessly (: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.