views:

1642

answers:

1

I have a shortcut on my desktop which opens a command prompt with many arguments that I need. I set the 'start in' field to d:\ and it works as expected (the prompt starts in d:). When I choose Advanced -> run as administrator and then open the shortcut, it starts in C:\Windows\System32, even though I have not changed the 'start in' field. How can I get it to start in d:\?

+2  A: 

If you use the /k argument, you can add a single line to execute a change drive and change directory. For instance:

C:\Windows\System32\cmd.exe /k "d: & cd d:\storage"

Using & you can string together many commands on one line.

Edit: You can also change drive with the cd command alone "cd /d d:\storage". Thanks to Adam Mitz for the comment.

Joseph Daigle
why not just use one command? cd /d d:\storage
Adam Mitz
I did not know the change directory command did that. Good to know.
Joseph Daigle
Yep... there's a surprising amount to learn in cmd.exe.
Adam Mitz