# Use Windows

Once Windows is installed, sign in, run programs, keep drivers and firmware current, and recover it when it won't start.

## Sign in

The first start signs in by itself. At the lock screen, this types the machine's saved password once the password box is ready:

```sh
osmates vm sign-in win
```

If the sign-in keyboard can't type your password, see [Type with another keyboard layout](https://osmates.com/docs/keyboard#type-with-another-keyboard-layout).

## Run programs

Programs run as LocalSystem, the system account:

```sh
osmates vm exec win -- cmd.exe /c ver
```

Add `--arch x64` to run a program's x64 code. For files, see [Copy files and share folders](https://osmates.com/docs/files).

## Stop Windows

To shut Windows down:

```sh
osmates vm stop win
```

Without the guest agent, Windows gets the power button and 30 seconds. While it installs updates, OSMates waits up to 2 hours, with the progress in `osmates vm info win`. `--force` turns the machine off at once, which can break Windows during an update.

## Use 3D graphics

Windows draws 3D in software with WARP, not on your Mac's GPU.

| Program | What it gets |
|---|---|
| Direct3D 9, 11, and 12 | Software rendering. Direct3D 12 reaches feature level 12_1. |
| Edge and WebView2 | WebGL in software |
| WebGPU | No adapter |
| OpenGL, x64 or Arm64 | OpenGL 1.1, or 4.6 with Microsoft's compatibility pack |

For OpenGL 4.6, install **OpenCL, OpenGL, and Vulkan Compatibility Pack** from the Microsoft Store in Windows.

## Virtual hardware

Windows runs on the OSMates engine, with Secure Boot and a TPM 2.0 that the machine keeps. `osmates vm info win` shows the hardware.

### Rename the processor

Windows sees OSMates Virtual CPU on every Mac. To change the name:

1. Shut the machine down.
2. Choose **Machine > Machine Settings**, then click **Hardware**.
3. Enter a name in **Processor Name**.

Windows shows it from the next start. In Terminal, run `osmates vm set win --processor-name "My CPU"`.

### Update the drivers

Windows uses virtio-win 0.1.302 drivers for the display, network, and shared folders. When an OSMates update brings newer ones, the next start from disk installs them. Those devices drop out for about a minute.

A snapshot named `Before Windows drivers <set>, <date and time>` comes first. To undo the update, revert to it. To install the newer drivers again later:

```sh
osmates vm start win --install-drivers
```

### Update the firmware

1. Shut the machine down.
2. Choose **Machine > Machine Settings**, then click **Hardware**.
3. Click **Update Firmware**, then click **Update**.

OSMates saves a `Before firmware <version>` snapshot first. Windows then starts twice without a window, to suspend and resume BitLocker. Until then, the drive's key is unprotected. In Terminal, run `osmates vm update-firmware win`.

If the guest agent doesn't answer, nothing changes. Suspend BitLocker in Windows and shut it down. Then click **Update Without Asking Windows**, or add `--without-agent`. Without that suspend, Windows asks for its recovery key at the next start.

## If Windows won't start

After two failed starts, Windows opens its recovery environment. OSMates stops a machine that restarts 5 times in a row within 3 minutes each. `osmates vm info win` shows the stop code.

Recovery can ask for the BitLocker recovery key. It's in [your Microsoft account](https://aka.ms/myrecoverykey), and while Windows runs, this shows it:

```powershell
manage-bde -protectors -get C:
```

If the display driver stops, the window shows Basic Display at 1024 x 768. Input and `vm exec` still work. Revert to the snapshot from before a driver update. To start once without the virtual GPU, hold Option and choose **Machine > Start with Basic Display**, or run `vm start --basic-display`.

The machine pauses when it can't save its TPM state, and won't start if that state changed outside OSMates. `osmates vm info win` says how to recover.
