3

So, as the title says, I would like to change the message from "press enter to continue", to "press enter to return to the menu". is this possible? if so can someone hook me up with a script line for it? I can post the code here if this may help. thank you in advance.

mklement0
  • 382,024
  • 64
  • 607
  • 775
Heine Berg
  • 43
  • 1
  • 5
  • Assuming you're talking about `cmd /c pause`: Use `Read-Host` instead, which allows you to customize the prompt message: `Read-Host 'press enter to return to menu'` – mklement0 Mar 04 '19 at 10:37

1 Answers1

3

Since pause is a function, it can be overridden. Let's first see the command:

Get-Command -Name pause | select *

HelpUri             :
ScriptBlock         : $null = Read-Host 'Press Enter to continue...'
CmdletBinding       : False
DefaultParameterSet :
Definition          : $null = Read-Host 'Press Enter to continue...'
Options             : None
...

As can be seen, the ScriptBlock is quite simple. A change in function definition is like so,

PS C:\> pause
Press Enter to continue...:
PS C:\> function pause{ $null = Read-Host 'Press Any Key or Enter to continue...' }
PS C:\> pause
Press Any Key or Enter to continue...:
PS C:\>

Since it's a built-in function, overriding the message must be done in profile or script file. Otherwise, the default text will re-emerge.

vonPryz
  • 22,996
  • 7
  • 54
  • 65
  • 1
    thanks mate, i didnt see your answer, but i worked around my problem. i exchanged pause with read host. the code i used was: Read-Host -Prompt "Press Enter to return to menu" i will use your information in further projects tho. thanks – Heine Berg Mar 04 '19 at 10:44