How to quickly enable and disable Aero in Windows 7?

8

5

I share my screen with colleagues a lot. During sharing, it's advisable to turn off Aero as it generates much more graphics to send over the wire and causes delays in screen sharing. Some screen sharing applications actually do this for you, and some don't.

I'm looking for a quick and convenient way to switch on/off Aero on Windows 7. Ultimately, if I could tie it to a hotkey, that would be best, but any widget/tray-icon or desktop shortcut would do.

Jonathan

Posted 2010-11-11T09:39:58.037

Reputation: 3 371

What software are you using that doesn't do this FOR YOU when you turn on screen sharing? :/ I can't think of any mainstream ones that don't support it by now. – Shinrai – 2010-11-11T15:28:09.420

Answers

10

Create a batch file with the following content:

@echo off
sc interrogate uxsms | find "1062"
if %errorlevel%==0 goto :sc_start
sc stop uxsms
exit

:sc_start
sc start uxsms
exit

Executing it will alternatively turn Aero on and off. You can place it anywhere you like. AFAIK it does not need to be executed as Admin.

molgar

Posted 2010-11-11T09:39:58.037

Reputation: 1 551

1This seems to require admin mode on windows 7. Regardless, this is excellent. – Frank V – 2013-02-25T01:00:58.457

3

You can try:

c:\> sc stop uxsms

c:\> sc start uxsms

enlavin

Posted 2010-11-11T09:39:58.037

Reputation: 51

0

Stop, this service is too much. I strongly recommend that we use the native API Windows.

An example of code in PowerShell:

# Definition des fonctions natives Windows permettant le test d'activation d'Aero et l'activation ou non d'Aero
$def = @"

    [DllImport("dwmapi.dll", PreserveSig = false)]
    public static extern bool DwmIsCompositionEnabled();

    [DllImport("dwmapi.dll", PreserveSig=false)]
    public static extern int DwmEnableComposition(bool fEnable);

"@
# Chargement de la fonction native dans un namespace personnel
Add-Type -Namespace MaifCode -Name Aero -MemberDefinition $def


# Fonction qui check si Aero est desactive ou non
function Check-Is-Aero{
    [CmdletBinding()]
    param()
    Write-Verbose "[$([DateTime]::Now)] ==> Test de la presence du mode Aero pour la session utilisateur $env:USERNAME"
    if([MaifCode.Aero]::DwmIsCompositionEnabled()){
        Write-Verbose "[$([DateTime]::Now)] ==> Aero actif pour la session utilisateur $env:USERNAME"
        return $true
    }
    else{
        Write-Verbose "[$([DateTime]::Now)] ==> Aero inactif pour la session utilisateur $env:USERNAME"
        return $false
    }
}

# Fonction qui test si Aero est actif et le desactive dans ce cas
function Disable-Aero{
    [CmdletBinding()]
    param()
    # Test si aero actif
    If(Check-Is-Aero) {
        Write-Verbose "[$([DateTime]::Now)] ==> Tentative de desactivation du mode Aero pour la session utilisateur $env:USERNAME"
        # Desactivation du mode aero
        try{
            $resultat = [MaifCode.Aero]::DwmEnableComposition($false)
        }
        catch [exception]
        {
            # Si erreur alors on sort et on affiche le message d'erreur
            Write-Error "Erreur dans l'execution de la desactivation du mode Aero : $error"
            exit -1
        }
        Write-Verbose "[$([DateTime]::Now)] ==> Desactivation du mode Aero pour la session utilisateur $env:USERNAME terminee"
    }
    else{
        Write-Verbose "[$([DateTime]::Now)] ==> sortie du script sans action"
    }
}

Nicolas

Posted 2010-11-11T09:39:58.037

Reputation: 11