![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | script location and $pwd I have a script which loads a .Net dll like this [reflection.assembly]::loadfrom("$pwd\lvl1\lvl2\bin\debug\target.dll") Works great when I am in the same directory as the script. When I Set-Location to the directory below and execute this script file ...\test.ps1 The loadfrom fails. How can I guard against this? The $MyInvocation.MyCommand.Defintion is empty (works great if the script is in a directroy that is in my path though) Thanks |
My System Specs![]() |
| | #2 (permalink) |
| Guest | RE: script location and $pwd I think you need to define the fullpath to the dll if you are not in the same directory as the script -- Richard Siddaway Please note that all scripts are supplied "as is" and with no warranty "Doug" wrote: > I have a script which loads a .Net dll like this > > [reflection.assembly]::loadfrom("$pwd\lvl1\lvl2\bin\debug\target.dll") > > Works great when I am in the same directory as the script. > > When I Set-Location to the directory below and execute this script file > > ..\test.ps1 > > The loadfrom fails. > > How can I guard against this? > The $MyInvocation.MyCommand.Defintion is empty > (works great if the script is in a directroy that is in my path though) > > Thanks |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: script location and $pwd RichS wrote: > I think you need to define the fullpath to the dll if you are not in the same > directory as the script There should be a way to get the path to the currently-executing script, though... |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: script location and $pwd "Adam Milazzo" wrote: > RichS wrote: > > I think you need to define the fullpath to the dll if you are not in the same > > directory as the script > > There should be a way to get the path to the currently-executing script, > though... > Yes, I am looking for that. I shuttle this code from my home machine to my work machine and would like to not have to update the script each time. |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: script location and $pwd Have you seen this article http://blogs.msdn.com/powershell/arc...-run-from.aspx $MyInvocation.MyCommand.Path may do what you want "Doug" wrote: > > "Adam Milazzo" wrote: > > > RichS wrote: > > > I think you need to define the fullpath to the dll if you are not in the same > > > directory as the script > > > > There should be a way to get the path to the currently-executing script, > > though... > > > > Yes, I am looking for that. I shuttle this code from my home machine to my > work machine and would like to not have to update the script each time. |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Include another script, keep variables in included script? | pschmidt | PowerShell | 32 | 08-18-2008 01:48 PM |
| script location? | Justin Rich | PowerShell | 5 | 05-15-2008 11:55 AM |
| BUG? Invalid location after Set-Location \\MyMachine | Roman Kuzmin | PowerShell | 3 | 04-01-2008 11:13 AM |
| Copying files from the same location as the script | greatbarrier86 | PowerShell | 5 | 01-13-2008 11:08 AM |
| how to determine a script location? | Jeff Jarrell | PowerShell | 6 | 06-01-2007 02:56 PM |