Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a shortcut start in a different directory when running it as an administrator on Windows Vista?

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:\?

like image 853
Sam S Avatar asked Sep 16 '08 00:09

Sam S


People also ask

How do I open a Command Prompt in a specific folder?

What to Know. Type cmd into the search bar to open the command prompt. Shift + right click in a window, then click Open PowerShell Window here to access the PowerShell interface. Open the folder you wish to access, then type cmd into the folder path at the top of the window to open a command prompt within the folder.

How do I run a Command Prompt as administrator?

You can open cmd as an administrator by searching for it in the Windows search bar located in the bottom left corner of the desktop screen. Then, right-click on Command Prompt and select Run as administrator.

How do I create a shortcut to run a command in Windows?

To do this, right-click in an empty space in File Explorer or the desktop. Then, go to New > Shortcut. ...then click Next. This is telling Windows to go into the system files and run the Command Prompt executable.


1 Answers

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.

like image 102
Joseph Daigle Avatar answered Sep 23 '22 07:09

Joseph Daigle