如何在 Windows 7 中永久更改命令提示符?

osc*_*tin 76 windows-7 command-line

我想将提示更改为$p$g$_$f永久,但每次重新打开命令窗口时它都会自行重置。

我怎样才能让它永远保持不变?

EBG*_*een 71

在命令提示符下键入:

setx Prompt $p$g$_$f
Run Code Online (Sandbox Code Playgroud)

然后重新打开命令提示符。

对于不知道如何获得 DOS/CMD 命令帮助的任何人,请键入:

setx /?
Run Code Online (Sandbox Code Playgroud)

要得到:

SetX has three ways of working:

Syntax 1:
    SETX [/S system [/U [domain\]user [/P [password]]]] var value [/M]

Syntax 2:
    SETX [/S system [/U [domain\]user [/P [password]]]] var /K regpath [/M]

Syntax 3:
    SETX [/S system [/U [domain\]user [/P [password]]]]
         /F file {var {/A x,y | /R x,y string}[/M] | /X} [/D delimiters]

Description:
    Creates or modifies environment variables in the user or system
    environment. Can set variables based on arguments, regkeys or
    file input.

Parameter List:
    /S     system          Specifies the remote system to connect to.

    /U     [domain\]user   Specifies the user context under which
                           the command should execute.

    /P     [password]      Specifies the password for the given
                           user context. Prompts for input if omitted.

    var                    Specifies the environment variable to set.

    value                  Specifies a value to be assigned to the
                           environment variable.

    /K     regpath         Specifies that the variable is set based
                           on information from a registry key.
                           Path should be specified in the format of
                           hive\key\...\value. For example,
                           HKEY_LOCAL_MACHINE\System\CurrentControlSet\
                           Control\TimeZoneInformation\StandardName.

    /F     file            Specifies the filename of the text file
                           to use.

    /A     x,y             Specifies absolute file coordinates
                           (line X, item Y) as parameters to search
                           within the file.

    /R     x,y string      Specifies relative file coordinates with
                           respect to "string" as the search parameters.

    /M                     Specifies that the variable should be set in
                           the system wide (HKEY_LOCAL_MACHINE)
                           environment. The default is to set the
                           variable under the HKEY_CURRENT_USER
                           environment.

    /X                     Displays file contents with x,y coordinates.

    /D     delimiters      Specifies additional delimiters such as ","
                           or "\". The built-in delimiters are space,
                           tab, carriage return, and linefeed. Any
                           ASCII character can be used as an additional
                           delimiter. The maximum number of delimiters,
                           including the built-in delimiters, is 15.

    /?                     Displays this help message.

NOTE: 1) SETX writes variables to the master environment in the registry.

      2) On a local system, variables created or modified by this tool
         will be available in future command windows but not in the
         current CMD.exe command window.

      3) On a remote system, variables created or modified by this tool
         will be available at the next logon session.

      4) The valid Registry Key data types are REG_DWORD, REG_EXPAND_SZ,
         REG_SZ, REG_MULTI_SZ.

      5) Supported hives:  HKEY_LOCAL_MACHINE (HKLM),
         HKEY_CURRENT_USER (HKCU).

      6) Delimiters are case sensitive.

      7) REG_DWORD values are extracted from the registry in decimal
         format.

Examples:
    SETX MACHINE COMPAQ
    SETX MACHINE "COMPAQ COMPUTER" /M
    SETX MYPATH "%PATH%"
    SETX MYPATH ~PATH~
    SETX /S system /U user /P password  MACHINE COMPAQ
    SETX /S system /U user /P password MYPATH ^%PATH^%
    SETX TZONE /K HKEY_LOCAL_MACHINE\System\CurrentControlSet\
         Control\TimeZoneInformation\StandardName
    SETX BUILD /K "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows
         NT\CurrentVersion\CurrentBuildNumber" /M
    SETX /S system /U user /P password TZONE /K HKEY_LOCAL_MACHINE\
         System\CurrentControlSet\Control\TimeZoneInformation\
         StandardName
    SETX /S system /U user /P password  BUILD /K
         "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\
         CurrentVersion\CurrentBuildNumber" /M
    SETX /F ipconfig.out /X
    SETX IPADDR /F ipconfig.out /A 5,11
    SETX OCTET1 /F ipconfig.out /A 5,3 /D "#$*."
    SETX IPGATEWAY /F ipconfig.out /R 0,7 Gateway
    SETX /S system /U user /P password  /F c:\ipconfig.out /X
Run Code Online (Sandbox Code Playgroud)

  • 我真的不在乎谁被标记为答案。不过,我会指出以供将来参考(保持原样)标记答案的关键决定不是谁先回答,而是哪个答案最好。虽然标记答案确实很好,因为它提供了代表,但标记答案的真正*原因*是帮助后来找到这个问题的人更快地找到最佳解决方案。由于在这种特殊情况下其他解决方案没有任何问题,因此无关紧要。 (30认同)
  • 我同意这与第一个答案无关。你们都回答了我关于如何永久更改提示的基本问题。当两个人实现同样的事情时,回退是使用第一个答案。你的简短而中肯,解决了基本问题,而他的则是一种更复杂的 UI 跳转方法,它公开了更多关于环境变量的选项。在选择答案之前,我仔细权衡了选项。 (3认同)
  • 扩展您的答案会很棒。它目前缺乏上下文。请查看我们简短的 [如何回答](http://superuser.com/questions/how-to-answer) 指南,了解如何更好地回答问题。那么,`setx` 究竟做了什么,为什么它会不断重置自己? (2认同)

Joh*_*n T 67

创建一个名为 PROMPT 的新环境变量。将变量值设置为所需的提示。

在此处输入图片说明

在此处输入图片说明

  • EBGreen 和 Randolf Richardson,“_在第一句话中_”是从你们两个逃脱的吗? (5认同)
  • +1 因为是在第一句话中提到重要事情的唯一答案。一旦知道命令解释器发出的提示是由环境变量控制的,其余的就变成了应用[关于环境变量的通用超级用户回答](http://superuser.com/questions/284342/) 的简单练习。 (2认同)
  • 从技术上讲,我的回答也提到了 Prompt 变量,因为它提供了设置它的命令。:) (2认同)

Ran*_*son 21

要更改 DOS 提示符(或“命令提示符”)的外观,请右键单击“计算机”(通常在 Windows 桌面或 Windows 开始菜单中),然后执行以下步骤:

  1. 单击“高级系统设置”标签
  2. 单击“环境变量...”按钮
  3. 单击“新建...”按钮(“用户变量”仅影响您,“系统变量”影响所有用户)
  4. 创建一个名为“PROMPT”的变量并插入您想要的提示文本(正如我在下面的最后一张图片中为您提供的)
  5. 单击“确定”按钮关闭“环境变量”窗口
  6. 单击“确定”按钮关闭“系统属性”窗口

此更改也将在重新启动后继续存在。

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

  • @Konerak:谢谢!我打开每个窗口,按下 Alt-PrintScreen(将当前活动窗口复制到剪贴板),然后将其粘贴到 Adob​​e Photoshop 中。之后,我在图像的顶部(或前面)创建了一个图层,用 100% 的黑色填充它,将图层的不透明度更改为 25%(这允许图像以 75% 的级别淡入),然后我使用带有“3px 羽毛”的 _Rectangular Marquee Tool_ 选择要突出显示的区域并按下 Delete 键(从这个黑色图层中删除)。之后,我将图像保存为 C:/Temp/ 目录中的 .PNG 文件并将其上传到此处。 (4认同)
  • 我喜欢你如何突出显示在每个图像中单击的位置。你是如何做到这一点的? (2认同)

小智 5

编辑启动命令提示符的菜单命令或链接,更改其目标,例如。

%SystemRoot%\system32\cmd.exe /K "prompt $p$g$_$f"
Run Code Online (Sandbox Code Playgroud)

如果想要在光标前有一个额外的空间:

%SystemRoot%\system32\cmd.exe /K "prompt $p$g$_$f "
Run Code Online (Sandbox Code Playgroud)


归档时间:

查看次数:

16536 次

最近记录:

6 年,1 月 前