0

I have a program on my system called stopwatch.exe, so sometimes I will have PowerShell open, and I will enter the command. However I also use tab completion, so I will usually enter:

stopw TAB

then press enter. However if on accident I enter:

stop TAB

Then I instead get Stop-Computer, which shuts down the computer. I have done this on accident now at least twice, and its very annoying. Does anyone has a solution for this problem? I know with the old shutdown.exe, you could enter shutdown /a to cancel it, but I dont know if anything like that is available with PowerShell.

https://docs.microsoft.com/powershell/module/microsoft.powershell.management/stop-computer

1
  • 2
    stupid old hack - keep an unsaved copy of notepad open and see if that stops things from rebooting..
    – Journeyman Geek
    Commented Nov 3, 2021 at 2:48

1 Answer 1

1

You can edit this file:

C:\PowerShell\Modules\Microsoft.PowerShell.Management\Microsoft.PowerShell.Management.psd1

Just comment out this line, or remove it:

"Stop-Computer",

You wont be able to shut down with PowerShell, but I dont think I have ever wanted or needed to do that. You can just push the power button on your computer, or shut down from the Start Menu.

1
  • And for anyone who does not have this folder as mentioned in Steven Penny's answer (C:\PowerShell\Modules), you can check the paths which it may exist otherwise on your system by running $Env:PSModulePath in PowerShell, and then per the output from there, you will get some directory listings which to check for this file as mentioned here if you cannot find it per this advice on the location of the file to adjust. Commented Nov 11, 2021 at 2:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .