Empowering WinPE with a Browser-Based VNC
Empowering WinPE with a Browser-Based VNC
Hey tech enthusiasts! If you’re into tweaking and optimizing system environments, you’re in for a treat. Today, we’re diving into a cool project that integrates a Virtual Network Computing (VNC) server into the Windows Preinstallation Environment (WinPE). This setup uses NoVNC, Websockify (powered by Node.js), and a Python-based HTTP server to make remote management a breeze. Let’s get into the details and see how you can supercharge your WinPE environment!
What’s the Deal?
The WinPE VNC Server Project is all about setting up a VNC server within WinPE, enabling you to control systems remotely. The project builds on an older guide by sjkingo/winpe_vnc, but it’s been updated for today’s tech. This setup allows you to access a browser-based VNC client from anywhere on your local network—or even beyond, with a bit of port forwarding.
Quick Navigation
Disclaimer
A quick heads-up: This project is shared as-is. While it’s designed to work, I can’t take responsibility for any mishaps—like your local IT getting annoyed if you port-forward the VNC server, or any other unforeseen drama.
What Can You Do with This?
- Run a VNC Server in WinPE: Access and control systems remotely while they’re running WinPE.
- Use a Browser-Based VNC Client: Connect from any modern web browser—super convenient!
- Local Network Access: Reach the VNC server within your local network. Port forwarding can give you access from anywhere.
What You Need
Here’s the tech stack for this setup:
- A Windows 10/11 system: You’ll need a host system to build your WinPE environment.
- Node.js: For running Websockify.
- Python 3.12: This version was tested, but others might work.
- TightVNC: Essential for the VNC server functionality.
How to Set It Up
1. Set Up WinPE
Start by creating your WinPE environment. Follow Microsoft’s official guide and place your build files in C:\WinPE\
.
2. Mount the WinPE Image
You’ll need to mount the boot.wim
file to make changes:
DISM /Mount-Image /ImageFile:C:\WinPE\media\sources\boot.wim /MountDir:C:\WinPE\mount /Index:1
3. Install TightVNC
Download and install TightVNC. Configure it as a system service, set a password (if desired), and adjust the port if needed (default is 5900).
4. Export TightVNC Config
Grab the necessary registry keys and files:
mkdir C:\VNC
reg export "HKEY_LOCAL_MACHINE\SOFTWARE\TightVNC" C:\VNC\vnc.reg
copy C:\Program Files\TightVNC\*.* C:\VNC\
5. Prepare Server Files
Get the project files from this repository or download pre-built executables and extract them to C:\VNC\
. Make sure you have a server folder in C:\VNC\server\
.
6. Install Node.js and Python Dependencies
Install the tools you’ll need:
pip install PyInstaller
npm install --save @maximegris/node-websockify
npm install pkg
7. Build Standalone Executables
Create standalone executables for WinPE:
python -m PyInstaller --onefile C:\VNC\server\winpe_httpserver.py
pkg -t node*-win-x64 C:\VNC\winpe_vnc.js
8. Copy Files to WinPE
Move C:\VNC
to C:\WinPE\mount\Windows\
.
9. Add NirCMD
Download NirCMD and put nircmd.exe
in C:\WinPE\mount\Windows\System32\
.
10. Configure Startnet.cmd
Update C:\WinPE\mount\Windows\System32\startnet.cmd
to auto-launch VNC components:
@echo off
wpeinit >nul 2>&1
wpeutil InitializeNetwork
wpeutil DisableFirewall
powercfg /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
cd X:\
regedit /s X:\Windows\VNC\vnc.reg
X:\Windows\VNC\tvnserver.exe -install -silent
X:\Windows\VNC\tvnserver.exe -start
X:\Windows\System32\nircmd.exe exec hide "X:\Windows\VNC\winpe_vnc.exe"
cd X:\Windows\VNC\server
X:\Windows\System32\nircmd.exe exec hide "winpe_httpserver.exe"
cd X:\
ipconfig
11. Finalize
Close everything and unmount the WinPE image:
DISM /Unmount-WIM /MountDir:C:\WinPE\mount /Commit
Now, you can write the WinPE image to a USB drive or HDD. Check out Microsoft’s guide and Rufus for making a bootable drive.
Using Your Setup
When you boot into WinPE, startnet.cmd
will set up everything for you. Find the IPv4 address using ipconfig and connect via a web browser:
http://[IP ADDRESS]:[PORT (DEFAULT=8000)/#host=[IP ADDRESS]&port=[PORT (DEFAULT=8113)]
Example:
http://192.168.0.100:8000/#host=192.168.0.100&port=8113
By default, the winpe_httpserver serves the http server via port 8000, but a port can be specified using \path\to\winpe_httpserver.exe [PORT NUMBER]
. For instance, C:\VNC\winpe_httpserver.exe 80
will remove the need of specifying the port in the URL when accessing the VNC client. (Final URL would be something like http://192.168.0.100/#host=192.168.0.100&port=192.168.0.100
Hit “Connect” under the WinPEVNC logo.
Shoutouts
- NoVNC for the awesome browser-based VNC client.
- sjkingo for the foundational guide that inspired this project.
Contact
Let’s connect! Reach out if you have questions or just want to chat:
- Email: John@JohnLe.org
- Website: JohnLe.org
- Blog: JohnLe.org/blog
- LinkedIn: /in/JohnLe
- Hope this guide helps you set up a powerful remote management solution with WinPE. Happy tinkering!