![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Invoke-Expression executing a command with spaces I got confused with using quotes in invoke-expression command. I am trying to run the following command from powershell..The command takes a parameter t - template path "%SYSTEMDRIVE%\Program Files\Sample App\Fscstarter.exe" t "%SYSTEMDRIVE%\Templates Dir\template.fdb" Tried different approaches but get either a token not found exception or invalid expression error. $templatePath = "$env:SystemDrive:\Templates Dir" Invoke-Expression "`"$env:SystemDrive\Program Files\Sample App\Fscstarter.exe`" t $templatePath\template.fdb" Could someone help point out the bleeding obvious mistake i am making? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Invoke-Expression executing a command with spaces Doe's this work? & "$env rogramfiles\Sample App\Fscstarter.exe" t "$env:SystemDrive\TemplatesDir" ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic Quote: > I got confused with using quotes in invoke-expression command. > I am trying to run the following command from powershell..The command > takes > a parameter t - template path > "%SYSTEMDRIVE%\Program Files\Sample App\Fscstarter.exe" t > "%SYSTEMDRIVE%\Templates Dir\template.fdb" > Tried different approaches but get either a token not found exception > or invalid expression error. > > $templatePath = "$env:SystemDrive:\Templates Dir" Invoke-Expression > "`"$env:SystemDrive\Program Files\Sample App\Fscstarter.exe`" t > $templatePath\template.fdb" > > Could someone help point out the bleeding obvious mistake i am making? > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Invoke-Expression executing a command with spaces "Ashish" <Ashish@xxxxxx> wrote in message news:F936BC9A-AB6B-4D09-BF86-3641925A9635@xxxxxx Quote: >I got confused with using quotes in invoke-expression command. > I am trying to run the following command from powershell..The command > takes > a parameter t - template path > "%SYSTEMDRIVE%\Program Files\Sample App\Fscstarter.exe" t > "%SYSTEMDRIVE%\Templates Dir\template.fdb" > > Tried different approaches but get either a token not found exception or > invalid expression error. > > $templatePath = "$env:SystemDrive:\Templates Dir" > Invoke-Expression "`"$env:SystemDrive\Program Files\Sample > App\Fscstarter.exe`" t $templatePath\template.fdb" > > Could someone help point out the bleeding obvious mistake i am making? This article may also help - discusses the use of single quotes versus double quotes with invoke-expression .... Remoting Quoting http://www.microsoft.com/technet/scr...h/quoting.mspx -- Jon |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Invoke-Expression executing a command with spaces Hello Ashish, You should read this article by Keith Hill, particularly the part that explains the why the call operator (&) is necessary to invoke an application from a path that has spaces: http://keithhill.spaces.live.com/Blo...A97!6058.entry -- Kirk Munro Poshoholic http://poshoholic.com "Ashish" <Ashish@xxxxxx> wrote in message news:F936BC9A-AB6B-4D09-BF86-3641925A9635@xxxxxx Quote: >I got confused with using quotes in invoke-expression command. > I am trying to run the following command from powershell..The command > takes > a parameter t - template path > "%SYSTEMDRIVE%\Program Files\Sample App\Fscstarter.exe" t > "%SYSTEMDRIVE%\Templates Dir\template.fdb" > > Tried different approaches but get either a token not found exception or > invalid expression error. > > $templatePath = "$env:SystemDrive:\Templates Dir" > Invoke-Expression "`"$env:SystemDrive\Program Files\Sample > App\Fscstarter.exe`" t $templatePath\template.fdb" > > Could someone help point out the bleeding obvious mistake i am making? |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Invoke-Expression executing a command with spaces Thanks Shay,Jon and Kirk..The articles were indeed helpful ![]() And yeah, Shay's suggestion works for me. "Kirk Munro" wrote: Quote: > Hello Ashish, > > You should read this article by Keith Hill, particularly the part that > explains the why the call operator (&) is necessary to invoke an application > from a path that has spaces: > http://keithhill.spaces.live.com/Blo...A97!6058.entry > > -- > Kirk Munro > Poshoholic > http://poshoholic.com > > > "Ashish" <Ashish@xxxxxx> wrote in message > news:F936BC9A-AB6B-4D09-BF86-3641925A9635@xxxxxx Quote: > >I got confused with using quotes in invoke-expression command. > > I am trying to run the following command from powershell..The command > > takes > > a parameter t - template path > > "%SYSTEMDRIVE%\Program Files\Sample App\Fscstarter.exe" t > > "%SYSTEMDRIVE%\Templates Dir\template.fdb" > > > > Tried different approaches but get either a token not found exception or > > invalid expression error. > > > > $templatePath = "$env:SystemDrive:\Templates Dir" > > Invoke-Expression "`"$env:SystemDrive\Program Files\Sample > > App\Fscstarter.exe`" t $templatePath\template.fdb" > > > > Could someone help point out the bleeding obvious mistake i am making? > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Re: running a program with spaces in Path with invoke-expression | PowerShell | |||
| Re: running a program with spaces in Path with invoke-expression | PowerShell | |||
| Using invoke-expression and folders containing spaces | PowerShell | |||
| invoke-expression with .exe that has spaces in its path | PowerShell | |||
| Issue: Invoke-Expression with $args in the expression | PowerShell | |||