![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | can't run script from folder containing spaces I am trying to run a script from a command prompt that is in folder containing spaces but I get the following error: C:\Temp\a b>.\test.ps1 The term 'C:\Temp\a' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again. At line:1 char:10 + C:\Temp\a <<<< b\test.ps1 It runs fine when there are no spaces in the path (e.g. I run it from c:\temp). I have also tried a number of variations around the full path, e.g. C:\Temp\a b>"c:\temp\a b\test.ps1" to no avail. I am sure this is something really simple but I can't see it! Many thanks! |
My System Specs![]() |
| | #2 (permalink) |
| | Re: can't run script from folder containing spaces If you use tab complete in powershell it will make it look like PS> & 'c:\temp\a b\test.ps1' You can also do PS> .\test.ps1 or PS> invoke-expression "C:\temp\'a b'\test.ps1" or PS> c:\temp\'a b'\test.ps1 "delta99" <delta99@discussions.microsoft.com> wrote in message news:4B851FAE-E968-464F-8161-A3CAE633B1F1@microsoft.com... >I am trying to run a script from a command prompt that is in folder > containing spaces but I get the following error: > > C:\Temp\a b>.\test.ps1 > The term 'C:\Temp\a' is not recognized as a cmdlet, function, operable > program, > or script file. Verify the term and try again. > At line:1 char:10 > + C:\Temp\a <<<< b\test.ps1 > > It runs fine when there are no spaces in the path (e.g. I run it from > c:\temp). > > I have also tried a number of variations around the full path, e.g. > > C:\Temp\a b>"c:\temp\a b\test.ps1" > > to no avail. > > I am sure this is something really simple but I can't see it! > > Many thanks! > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: can't run script from folder containing spaces Hi Brandon, Thanks for your suggestions - they work fine from a powershell window! However, I am trying to run the script from a DOS command prompt (or by double-clicking on the ps1 script in explorer) - if the path contains no spaces the script executes, otherwise it doesn't ... "Brandon Shell" wrote: > If you use tab complete in powershell it will make it look like > > PS> & 'c:\temp\a b\test.ps1' > > You can also do > PS> .\test.ps1 > or > PS> invoke-expression "C:\temp\'a b'\test.ps1" > or > PS> c:\temp\'a b'\test.ps1 > > "delta99" <delta99@discussions.microsoft.com> wrote in message > news:4B851FAE-E968-464F-8161-A3CAE633B1F1@microsoft.com... > >I am trying to run a script from a command prompt that is in folder > > containing spaces but I get the following error: > > > > C:\Temp\a b>.\test.ps1 > > The term 'C:\Temp\a' is not recognized as a cmdlet, function, operable > > program, > > or script file. Verify the term and try again. > > At line:1 char:10 > > + C:\Temp\a <<<< b\test.ps1 > > > > It runs fine when there are no spaces in the path (e.g. I run it from > > c:\temp). > > > > I have also tried a number of variations around the full path, e.g. > > > > C:\Temp\a b>"c:\temp\a b\test.ps1" > > > > to no avail. > > > > I am sure this is something really simple but I can't see it! > > > > Many thanks! > > > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: can't run script from folder containing spaces This should work powershell "c:\temp\'a b'\test.ps1" By default .ps1 are associated to notepad. This is for security reasons. Unless you changed that I dont expect the clicking to work. "delta99" <delta99@discussions.microsoft.com> wrote in message news:9755DEA8-EA35-4F19-8D08-A80E1E7E9776@microsoft.com... > Hi Brandon, > > Thanks for your suggestions - they work fine from a powershell window! > > However, I am trying to run the script from a DOS command prompt (or by > double-clicking on the ps1 script in explorer) - if the path contains no > spaces the script executes, otherwise it doesn't ... > > "Brandon Shell" wrote: > >> If you use tab complete in powershell it will make it look like >> >> PS> & 'c:\temp\a b\test.ps1' >> >> You can also do >> PS> .\test.ps1 >> or >> PS> invoke-expression "C:\temp\'a b'\test.ps1" >> or >> PS> c:\temp\'a b'\test.ps1 >> >> "delta99" <delta99@discussions.microsoft.com> wrote in message >> news:4B851FAE-E968-464F-8161-A3CAE633B1F1@microsoft.com... >> >I am trying to run a script from a command prompt that is in folder >> > containing spaces but I get the following error: >> > >> > C:\Temp\a b>.\test.ps1 >> > The term 'C:\Temp\a' is not recognized as a cmdlet, function, operable >> > program, >> > or script file. Verify the term and try again. >> > At line:1 char:10 >> > + C:\Temp\a <<<< b\test.ps1 >> > >> > It runs fine when there are no spaces in the path (e.g. I run it from >> > c:\temp). >> > >> > I have also tried a number of variations around the full path, e.g. >> > >> > C:\Temp\a b>"c:\temp\a b\test.ps1" >> > >> > to no avail. >> > >> > I am sure this is something really simple but I can't see it! >> > >> > Many thanks! >> > >> >> |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Spaces in script path | PowerShell | |||
| VBS script with spaces in executable path | VB Script | |||
| Re: VB Script Code to get alert when a folder get changed in intranet FTP Folder | VB Script | |||
| Passing parameters to PS script and escaping spaces | PowerShell | |||
| script with spaces in the path | PowerShell | |||