8

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.

1
  • 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
    Nov 11, 2010 at 15:28

3 Answers 3

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.

1
  • 1
    This seems to require admin mode on windows 7. Regardless, this is excellent.
    – Frank V
    Feb 25, 2013 at 1:00
3

You can try:

c:\> sc stop uxsms

c:\> sc start uxsms
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"
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.