Friday, July 31, 2009

How do I open a command prompt to a specific directory without changing the defaults?

I need the syntax to open a cmd window to a specifc diretory. I have tried clicking on Run: then entering the following





cmd /k c:\Documents and Settings





This does not work





I need to know how to do this from the Run line becasue I really need the syntax to be used in a Java program I am writing..Alternative methods of opening a cmd promt wont do me any good Thanks for any help

How do I open a command prompt to a specific directory without changing the defaults?
cd c:\documents and settings





may try also





cd "C:\documents and settings"
Reply:You need the CD command before the path, and quotes around it if there are spaces.





so it becomes this:





cmd /k "cd c:\Documents and Settings"





Although if it is on another drive you have to change drives after it has started, I'm not sure how to do it directly.





--------------------





Alternatively, you can have your Java program write a batch script like this:





CD (directory) - changes path


C: - changes drives


(other dos commands here)





And call cmd /k (generated batch file)

quince

No comments:

Post a Comment