Friday, December 30, 2016

windows - Batch file for starting powershell in a specific directory



I am learning to program in python through the book "Learn python the hard way".
Therefore I use powershell to run my programs.
Since I had to manually change the directory every-time I started powershell , I wrote a batch file to automate it.



The command I wrote is :



powershell.exe -noexit -command "'cd c:\self\pooja\"edu n career"\programs\python'"



The problem is that it runs but opens the directory of "programs" only.
Why is it not changing to python directory?



Finally , I did it by setting the "Start in" field in the shortcut property of powershell but I want to know why the batch file is not working as expected.


Answer



Close Nate, but that doesn't work when I run it on a "New Folder". Had to move the CD outside the single quotes to make it work.



powershell.exe -noexit -command "cd 'c:\New folder'"
powershell.exe -noexit -command "cd 'c:\self\pooja\edu n career\programs\python'"


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...