« Vimperator for Firefox | Main | Modifying the home in PowerShell »
Recently I was writing a small script for Powershell and I needed to call an external program from my script. However, I wanted to be able to put keep the directory the executable was located in in a variable; you know, like one usually does in regular batch files.
After searching around using google, I found that you can execute the contents of a string as a command by prefixing it with '&', like this:
This is fine if you've got a simple literal string. However, if you want to use the value of one or more variables in it, you of course need to switch to using double quotes instead, like this:
Turns out you can actually execute the contents of a variable as a command, which I wasn't expecting to work at first:
Pretty nifty!
About
Tomas Restrepo is co-founder of devdeo. His interests include .NET, Connected Systems, PowerShell and, lately, dynamic programming languages. More...
email: tomas@winterdom.com msn: tomasr@passport.com twitter: tomas_restrepo
Technorati Profile
Syndicate
Ads
Links
Categories
Statistics
Blogroll
Post Archive
Other
Copyright © 2002-2008, Tomas Restrepo.
Powered by: newtelligence dasBlog 1.9.7174.0