Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Script:
# Define the orientation options
$orientations = @{
"0" = "Landscape"
"1" = "Portrait"
"2" = "Landscape (flipped)"
"3" = "Portrait (flipped)"
}
# Prompt user for the desired orientation
Write-Host "Select the monitor orientation:"
$orientations.GetEnumerator() | ForEach-Object { Write-Host "$($_.Key): $($_.Value)" }
$selection = Read-Host "Enter the number corresponding to the desired orientation"
# Validate the selection
if (-not $orientations.ContainsKey($selection)) {
Write-Host "Invalid selection. Exiting script."
exit
}
# Use the DisplaySwitch.exe utility to change the orientation
$orientationValue = $selection
$monitorId = 0 # Default to the primary monitor, change if needed
# Use PowerShell command to change the orientation
# Note: This requires administrative privileges
$command = "DisplaySwitch.exe /internal"
Start-Process -FilePath $command -ArgumentList "/rotate:$orientationValue" -Verb RunAs
Write-Host "Monitor orientation changed to $($orientations[$selection])."
Como Executar o Script:
Open PowerShell with administrative privileges. You can do this by searching for "PowerShell" in the Start menu, right-clicking it, and selecting "Run as administrator".
Copy the script above into a new file and save it with a .ps1
extension, for example, ChangeMonitorOrientation.ps1
.
In the PowerShell window, navigate to the directory where you saved the script using the cd
command.
Execute the script by typing .\ChangeMonitorOrientation.ps1
and pressing Enter.
Follow the on-screen instructions to select the desired monitor orientation by entering the corresponding number.
The script will change the monitor orientation to the selected option.