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

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

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

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

答案1

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

在此处输入图片描述

在此处输入图片描述

答案2

在命令提示符下输入:

setx Prompt $p$g$_$f

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

对于那些不知道如何获取 DOS/CMD 命令帮助的人,请输入:

setx /?

要得到:

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

答案3

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

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

此更改在重启后仍有效。

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

答案4

Windows 附带 Windows PowerShell,它允许流水线操作以及其他以前仅在 Linux 上实现的功能。

您可以通过单击“开始”按钮并输入 PowerShell 来启动它,它为您提供了三个选项。单击 PowerShell。右键单击窗口标题栏并选择属性。在打开的窗口中,您可以配置视图和行为设置。

否则,不要首先打开 PowerShell,而是选择并单击 PowerShell 模块。

请参阅 Microsoft 文档以了解您可以执行的操作:

PS:如果您开发控制台应用程序,我不建议使用经典 shell。

相关内容