【问题标题】:Change default starting directory of cmd.exe on windows 10在 Windows 10 上更改 cmd.exe 的默认起始目录
【发布时间】:2016-07-28 20:09:25
【问题描述】:

当使用键序列Super-x c(“超级”是指 Windows 键,无论其名称是什么)打开时,如何更改 Windows 10 上 cmd.exe 的默认起始目录?我可以通过修改

中的条目来更改开始菜单中的链接

"%APPDATA%\Microsoft\Windows\Start Menu\Programs\System Tools\Command Prompt.lnk"

使用visual basic或其他方式,但它不会影响我打开提示的正常方式,即上面的键序列。我只想将工作目录更改为我设置为“%HOME%”的环境变量的值。

【问题讨论】:

标签: windows cmd windows-10


【解决方案1】:

正如@JosefZ 在他的评论中显示的那样,要查看的目录是"%LOCALAPPDATA%\Microsoft\Windows\WinX\Group3"。为了结束这个问题,我可以用一个简单的批处理脚本来修改快捷方式, 基本上就是下面这个,会修改开始菜单中链接的起始目录,以及user/admin的win-x链接。

:: preamble stuff
set "startup=%APPDATA%\Microsoft\Windows\Start Menu\Programs\System Tools"
call :modifyLink "%startup%\Command Prompt.lnk"
call :modifyLink "%LOCALAPPDATA%\Microsoft\Windows\WinX\Group3\01 - Command Prompt.lnk"
call :modifyLink "%LOCALAPPDATA%\Microsoft\Windows\WinX\Group3\02 - Command Prompt.lnk"

:EOF

:modifyLink
set tscript="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo.Set sh = CreateObject("WScript.Shell") > "%tscript%"
echo.Set shortcut = sh.CreateShortcut("%~1") >> "%tscript%"
echo.shortcut.WorkingDirectory = "%HOME%" >> "%tscript%"
echo.shortcut.Save >> "%tscript%"

cscript /nologo "%tscript%"
del "%tscript%"

【讨论】:

    猜你喜欢
    • 2021-05-15
    • 1970-01-01
    • 1970-01-01
    • 2010-10-04
    • 2016-03-14
    • 2014-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多