I'm trying to change between my first monitor and both monitors on at the same time. When I use displayswitch.exe /internal or displayswitch.exe /extend on cmd they always work, however I cannot made this code to work inside the batch file. Can someone help me? Thx
@echo off
REM Check current display mode
powershell -command "(Get-WmiObject -Namespace root\wmi -Class WmiMonitorConnectionParams).Active"
REM Check if current mode is "Extend" or "Internal"
if "%ERRORLEVEL%"=="1" (
REM Current mode is "Extend", switch to "Internal"
echo Switching to Internal display mode...
displayswitch.exe /internal
) else (
REM Current mode is "Internal", switch to "Extend"
echo Switching to Extend display mode...
displayswitch.exe /extend
)
echo Display mode switched successfully.
pause
@%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -Command "(Get-WmiObject -Namespace root\wmi -Class WmiMonitorConnectionParams).Active"and 2.@Echo %ErrorLevel%& Pause. My best guess, regardless of the current mode, is that the ErrorLevel will always be0, as it is returning that thepowershell.exewas run successfully, not what the result of the-Commandwas.