Warning

 

Close
Confirm Action

Are you sure you wish to do this?

Cancel Confirm
AR15.COM
11/4/2012 7:54:17 AM EDT
I posted a thread a week or so ago about programming, well I am trying to get some basics down. I am currently having an issue with powershell, I have messed around with it doing basic commands. Right now I am trying to just change my directory and it won't let me go into certain ones and I can't figure out why. I can get into some but not others.

For example I can go into C:\Users\Username\documents but cannot get in to C:\Program Files? This is the error I get

Set-Location : A positional parameter cannot be found that accepts argument 'file'.

I don't recall having this problem when I was messing around with python.

Also my computer is setup with a SSD for the OS and a few other programs like MS Office everything else is run off the D drive which some registry edits were made. So far I have had no issues with this computer and I am pretty sure this issue is new and not related to that.

I am thinking of buying this book to read Learn Powershell In a Month of Lunches
11/4/2012 8:23:54 AM EDT
[#1]
I'm guessing the problem with going into the Program Files folder is the space.  Try putting quotes around the entire path.
11/4/2012 8:28:57 AM EDT
[#2]



Quoted:


I'm guessing the problem with going into the Program Files folder is the space.  Try putting quotes around the entire path.


Yarp.



PS C:\> cd program files

Set-Location : A positional parameter cannot be found that accepts argument 'files'.

At line:1 char:3

+ cd <<<<  program files

   + CategoryInfo          : InvalidArgument: (:) [Set-Location], ParameterBindingException

   + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetLocationCommand



PS C:\> cd "program files"

PS C:\program files>



 
11/4/2012 8:53:08 AM EDT
[#3]
Quoted:
I'm guessing the problem with going into the Program Files folder is the space.  Try putting quotes around the entire path.



Quoted:

Quoted:
I'm guessing the problem with going into the Program Files folder is the space.  Try putting quotes around the entire path.

Yarp.

PS C:\> cd program files
Set-Location : A positional parameter cannot be found that accepts argument 'files'.
At line:1 char:3
+ cd <<<<  program files
   + CategoryInfo          : InvalidArgument: (:) [Set-Location], ParameterBindingException
   + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

PS C:\> cd "program files"
PS C:\program files>
 


Thanks guys! that worked.

If you don't mind one more question.

I am trying to run the simple HelloWorldApp and i cannot set my system variable path. I went in to set it but I don't think it is right. So I am unable to compile the program to run.

I have downloaded the JDK 7 in my D drive so the path is

D:\Program Files\Java\jdk1.7.0_09\bin

I tried setting the system variable path through windows, I'm doing something wrong obviously. The instructions I had online didn't work either and I have no idea on how to set it through powershell.

Any thoughts on that book?
11/4/2012 8:56:19 AM EDT
[#4]
"C:\Program Files"



quotes are your answer.
11/4/2012 9:32:10 AM EDT
[#5]
Get current path:
[Environment]::GetEnvironmentVariable("Path","User")

Set path:
[Environment]::SetEnvironmentVariable("Path", "new value.", "User")