Open Powershell in a specific directory from shortcut

后端 未结 9 1601
再見小時候
再見小時候 2021-01-30 12:22

This sounds like it should be so simple... I must be dumb.

All I want is to make a windows short-cut that opens Powershell into a specific directory:

I\'m using

9条回答
  •  不知归路
    2021-01-30 12:50

    If you want powershell to start as admin and run in a specific directory, even on a different drive, it is better to use the Set-Location command. Follow these steps

    1. Create a ShortCutLink with the target being the powershellcommand exe.
    2. Leave Start in: blank. (Normally this starts in current working directory when blank; but we do not care.)
    3. Change Target to this with your targets for powershell and locations:

      C:\Windows\...\v1.0\powershell.exe -noexit -command "Set-Location D:\_DCode\Main"

    4. Click Advanced... and select Run as administrator.
    5. Click OKs out.

    Don't forget the handy trick to change the colors of the shortcut from the Colors tab. That way if you have two or more links which open powershell windows, seeing a different color can visually let you know which shell one is working in.

提交回复
热议问题