![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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 | Stumped by variable substitution 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. |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Stumped by variable substitution On May 14, 9:21 am, K Kong <K...@discussions.microsoft.com> 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. try that: $env:UserProfile.ToString()+"\"+$Env:username.ToString()+"\" + $microsoft[1].txt |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Stumped by variable substitution Why? "\microsoft[1].txt" is a string literal. Anyway, what you suggested produced an error as $microsoft is a null array. "Shafik" wrote: > try that: > $env:UserProfile.ToString()+"\"+$Env:username.ToString()+"\" + > $microsoft[1].txt |
My System Specs![]() |
| | #4 (permalink) |
| Newbie Rep Power: 11 ![]() | > PS C:\> get-content $CookieFile The []s are getting you in trouble as they look like a wildcard. Try: PS C:\> get-content -LiteralPath $CookieFile Jeffrey Snover [MSFT] Windows Management Partner Architect Visit the Windows PowerShell Team blog at: Windows PowerShell Visit the Windows PowerShell ScriptCenter at: Scripting with Windows PowerShell |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: Stumped by variable substitution 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.) Marco |
My System Specs![]() |
| | #6 (permalink) |
| Guest | Re: Stumped by variable substitution You are right! Thanks. "Marco Shaw" wrote: > > 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.) > > Marco > |
My System Specs![]() |
| | #7 (permalink) |
| Guest | 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 Specs![]() |
| | #8 (permalink) |
| Guest | Re: Stumped by variable substitution I ran into this last night (while backup up MP3's) If you use the -literalPath argument (rather than -Path), it doesn't try to interpret the wildcards: get-content -literalPath $CookieFile See "help -detailed get-content:" |
My System Specs![]() |
| | #9 (permalink) |
| Guest | Re: Stumped by variable substitution Right. Should have thought of this earlier. BTW, do you know of the syntax of the contents of the cookie files? I Googled but can't seem to find any information. I suppose this is specific and proprietary to IE. I can guess on the key/value pairs. But I can't decipher the expiry date. Is there an API to read the cookies? Thanks. "Keith Hill" wrote: > BTW to get the path to your Cookies folder I would use: > > PS> [Environment]::GetFolderPath([Environment+SpecialFolder]::Cookies) > > -- > Keith > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Command & variable substitution | Chris | PowerShell | 5 | 01-09-2008 07:45 AM |
| Stumped | Andy/Bandi | Vista file management | 6 | 06-17-2007 12:00 PM |
| Stumped | Andy/Bandi | Vista General | 19 | 06-16-2007 08:51 PM |
| HELP!! Totally stumped!! | ChrisW | Vista General | 6 | 04-08-2007 05:13 PM |
| How can I ensure that a variable is a built-in powershell variable? | Sung M Kim | PowerShell | 7 | 09-22-2006 06:28 PM |