Windows Powercfg, Hibernation, Sleep, Fast start, Restart and so on.

Windows has got a lot of puzzling shutdown options. Light in the dark comes here.

These shutdown and restart options do exist:

  1. Real shutdown: the computer is shutdown completely, no drivers or stuff is stored anywhere. When booting after the real shutdown, it is like in the ancient days. The computer boots afresh from the hard drive. Slow.
  2. Fake shutdown: this is the standard option in Windows 10. Drivers and stuff are copied from RAM to the drive and the computer is switched off.
    When booting again, drivers and stuff are read from hiberfil.sys.
  3. Hibernation: the computer’s complete RAM is stored in the hiberfil.sys, then it is switched off.
    When booting again all is read from the hiberfil, so you can continue exactly where you left. Computer does not use any energy in hibernation.
  4. Sleep: some energy consuming parts of the computer are switched off, but the RAM stays alive. Computer still uses some energy to keep the RAM alive.
  5. Restart: Like a real shutdown (1.) and boot.
  • Menu-Shutdown nowadays does only a fake shutdown, if hiberfil.sys usage is on. Then it stores drivers and stuff in the hiberfil.sys and reads them back from the hiberfil at startup. Therefore, shutting down and then booting your PC probably does not what you thought it does, namely a startup of a clean system.
  • Menu-Shutdown with pressing the Shift-Key: Does a real shutdown. Starting from here does a clean startup.

  • hiberfil.sys is used for fake shutdown and hibernation.

  • powercfg.exe /hibernate [on|off] switches on/off the creation of hiberfil.sys. So this also switches on/off the fake shutdown. If you get an error message about an unexpected error (0x65b) when running this, you should start cmd as Administrator.
  • powercfg.exe /hibernate [on|off] does not switch on/off the menu option for hibernation.
  • A restart always does a real restart, not a fake shutdown.
  • When hiberfil.sys is in use, you can put the computer to hibernation by shutdown /h and you can do a full shutdown by shutdown /s /t 1. You can put these commands directly into the target of a desktop shortcut. Use e.g. target C:\Windows\System32\shutdown.exe /h and run in C:\Windows. %SystemRoot%\System32\SHELL32.dll contains some icons for such a shortcut.
  • That’s not all. The hiberfil.sys can exist in several modes. In the reduced mode it cannot support hibernation, but only fake shutdown. In full mode it supports both, hibernation and fake shutdown. You can set reduced or full mode as an admin with powercfg: powercfg /h type reduced or powercfg /h type full

  • And there’s a registry key which determines which mode is used for hiberfil.
    Look under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power and there look for the DWORD HiberFileType. If that is on 1, the hibernation mode is not possible. Then, switch it to 2. The HiberFileType key’s values are:

  • The DWORD-value HibernateEnabled must be on 1.

  • Link

  • Link
  • Link

System Power States or Sleep States

MS defined 5 sytem power states, S1 to S5, also called sleep states sometimes. S5 being fully off and S4 being the hibernate state. S1-S3 are varying sllep modes, the higher the number, the more is switched off. It depends on the hardware which of these modes is supported.
powercfg -a in the shell lists available modes. On my it says:

Supported modes:
   Standby (S3)
   Ruhezustand                (resting state)
   Hybrider Standbymodus      (hybrid standby mode)
   Schnellstart               (quick start)

   S1, S2, S3

I do not know how S1 to S5 correlate to real shutdown, fake shutdown and so on. But from the result of powercfg -a it seems, there are states that do not correlate to these numbers at all. It’s all a big mess.

VisualStudio C# How to Suppress Warnings and Find Warning Numbers

Sometimes it is useful to suppress certain warnings in a certain piece of code. It is done like this:

#pragma warning disable 414, 302
   // hic sunt leones
#pragma warning restore 414, 302

But to disable a certain warning, you first need to know its number. Finding out this number is not easy if you don’t know how to.

The following resolution is copied from Stackoverflow, just as a reference for me, because I needed too much time to find the information in the first place. So here is how to find out C# warning numbers in VS2012:

The Error List hides the error and warning numbers, but if you open the **Output panel** in Visual Studio (menu : Debug > Windows > Output) and set it to show **output from Build**, you can find the warning number somewhere in the wall of text.

You could also try building the project from the command line (using msbuild) which will output and highlight all error and warning numbers.

How to Find out Where a Running Process is Located

Sometimes you want to find out where a running process resides on your drives. At least these methods are possible in Windows 10.

  • Taskmanager, process tab, right-click on the columns’ headers, select command line. A column with the full commandline which started the process is shown. If you’ve done this once, Taskmanager remebers that you want to have this column and shows it automatically next time.

  • In the cmd shell:
    wmic process where "name='xyz.exe'" get ProcessID, ExecutablePath

  • In a cygwin, mingw64 or git-bash:
    ps -Wefa | grep -i xyz.exe

Fehlermeldungen vom VisualStudio in deutsch

Wenn man das Pech hat, mit einer deutschen MS-Umgebung entwickeln zu müssen, hat man auch das Pech, dass viele Fehlermeldungen in deutsch ausgegeben werden und man im Netz nichts dazu findet. Zum Beispiel zu Ein Endpunktkonfigurationsabschnitt für Vertrag \”xyz\” konnte nicht geladen werden, da mehr als eine Endpunktkonfiguration für diesen Vertrag gefunden wurde. Geben Sie den bevorzugten Endpunktkonfigurationsabschnitt mit Namen an.

Es gibt Rettung: MS Fehlermeldungen auf deutsch

Non-english error messages from Visual Studio

If you’ve got to develop with on a non-english system, you’ve got the bad luck that many error messages you see are not in english and you don’t find anything in the web about e.g. Ein Endpunktkonfigurationsabschnitt für Vertrag \”xyz\” konnte nicht geladen werden, da mehr als eine Endpunktkonfiguration für diesen Vertrag gefunden wurde. Geben Sie den bevorzugten Endpunktkonfigurationsabschnitt mit Namen an.

There is a lifesaver: Non-english MS error messages