如何永久更改 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。

相關內容