View Single Post
Old 05-14-2007   #7 (permalink)
Keith Hill


 
 

Re: Stumped by variable substitution

"Marco Shaw" <marco.shaw@_NO_SPAM_gmail.com> wrote in message
news:%23XXCohilHHA.3704@TK2MSFTNGP02.phx.gbl...
>K Kong wrote:
>> What did I do wrong here? Why does the "\microsoft[1].txt" gets ignored?
>>
>> PS C:\>
>> $CookieFile=$env:UserProfile.ToString()+"\"+$Env:username.ToString()+"\microsoft[1].txt"
>> PS C:\> $CookieFile
>> C:\Documents and Settings\kingkong\kingkong\microsoft[1].txt
>> PS C:\> get-content $CookieFile
>> Get-Content : Cannot find path 'C:\Documents and
>> Settings\kingkong\kingkong' because it does not exist.
>> At line:1 char:12
>> + get-content <<<< $CookieFile
>> PS C:\>
>>
>> Thanks in advance.

>
> Seems Keith Hill mentions an issue with "[" and "]" in this thread
> "Scripting / Logging Gripe Summary" from May 12th. (I did not read it in
> detail though.)


Yeah the square braces can be a PITA if you don't want their wildcarding
behavior. In this case it should be enough to specify the last part of path
like so:

.... + 'microsoft[1].txt'

BTW to get the path to your Cookies folder I would use:

PS> [Environment]::GetFolderPath([Environment+SpecialFolder]::Cookies)

--
Keith

My System SpecsSystem Spec