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:
    0 – HIBERFILE_TYPE_NONE
    1 – HIBERFILE_TYPE_REDUCED
    2 – HIBERFILE_TYPE_FULL
    3 – HIBERFILE_TYPE_MAX

  • 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:

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

Disk ID, Volume ID and Tools to Change

There are several types of IDs for harddisks and volumes which you normally don’t notice and don’t need to know about.

Disk ID

Windows attaches a disk id it to every disk – not volume – it uses. You can look at it and change it with the command line tool diskpart which comes with Windows.

Open a cmd shell as admin, then

diskpart           starts it, it shows a prompt like `DISKPART>'
list disk          shows a list of phyisical disks, not volumes 
select disk 1      selects disk 1 as the 'current' disk
uniqueid disk      shows the disk id

uniqueid disk=[new id]  change disk id of the selected disk
help uniqueid disk   help for uniqueid command, shows 
                     details of [new id] in line above

     more possibilities of diskpart 
help             shows list of commands
list             shows help for the list command
list volume      all volumes of the computer
list partition   partitions of the selected disk

Volume ID

A volume id is attached to a partition or volume on a drive. How can you see the volume id of a drive?
open a cmd shell, then vol d: shows the name and volume id of drive d:.

Though you can do alot of stuff with the above mentioned diskpart, you cannot view or change a volume id with it. But you can download VolumeId, a tool from MS, which does just this: Change a volume id of a volume. Usage is easy, you need to open a cmd shell as admin and then

volumeid e: 1A34-AB27

changes the volume’s id to the value 1A34-AB27.