Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Restarting a computer is a common task for system maintenance, troubleshooting, or applying updates. In the Windows environment, this can be done using various methods, including graphical user interfaces and command-line tools. This article will focus on how to restart a computer using PowerShell and the Command Prompt (CMD).
Examples:
Restarting a Computer Using PowerShell:
PowerShell provides a straightforward command to restart a computer. You can use the Restart-Computer
cmdlet, which is specifically designed for this purpose.
Restart-Computer
This command will restart the local computer. If you need to restart a remote computer, you can specify the computer name using the -ComputerName
parameter.
Restart-Computer -ComputerName "RemotePC"
If you need to force applications to close during the restart process, you can add the -Force
parameter:
Restart-Computer -ComputerName "RemotePC" -Force
Additionally, you can specify credentials if you are not logged in with an account that has the necessary permissions:
$credential = Get-Credential
Restart-Computer -ComputerName "RemotePC" -Credential $credential
Restarting a Computer Using CMD:
The Command Prompt also provides a way to restart a computer using the shutdown
command. This command can be used to shut down or restart a computer.
To restart the local computer, use the following command:
shutdown /r /t 0
/r
tells the system to restart./t 0
sets the time-out period before shutdown to zero seconds.To restart a remote computer, you can use the /m
parameter to specify the remote machine:
shutdown /r /m \\RemotePC /t 0
If you need to force applications to close, you can add the /f
parameter:
shutdown /r /f /m \\RemotePC /t 0
The shutdown
command is versatile and can be used in batch scripts or scheduled tasks to automate the restart process.