Skip to content
/ WinPE-VNC Public

WinPE-VNC is a methodology of combining several technologies to properly create establish a VNC connection within WinPE. Available anywhere within a local area network (or external if port forwarding is setup).

Notifications You must be signed in to change notification settings

9-5/WinPE-VNC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

WinPE-VNC

This project creates a Virtual Network Computing (VNC) server within a Windows Preinstallation Environment (WinPE) using NoVNC, Websockify (built from Node.js), and a Python-based HTTP server. It also includes a self-hosted VNC client accessible from anywhere within the local network. It started as a simple project to be able to VNC into systems within my work environment following a guide from sjkingo/winpe_vnc, but I noticed there were some changes over the decade since the guide was written.

Table of Contents

  1. Disclaimer
  2. Features
  3. Requirements
  4. Setup Instructions
  5. Usage
  6. Contributing
  7. Acknowledgements
  8. FAQ
  9. Contact

Disclaimer

No liability is held by me in the event of: The VNC server is accessed due to it being port-forwarded and your local IT/system administrator getting very upset, the WinPE environment gaining sentience and taking over the world.

Features

  • A VNC server in the WinPE environment
  • A browser-based VNC client accessible from most modern browsers
  • Accessibilty to the VNC server from within the local network (port forwarding may allow for external access)

Requirements

  • A Windows 10/11 based system
  • Node.JS
  • Python 3.12 (may be varied, but tested on Python 3.12).
  • TightVNC

Setup Instructions

Video Tutorial coming soon...

  1. Follow Microsoft's guide on building WinPE. // This guide assumes that C:\WinPE\ is where the WinPE build files are stored.
  2. Once the environment is setup, mount the WinPE's boot.wim using the following command from Command Prompt as an Administrator: // This allows you to modify the WinPE filesystem. DISM /Mount-Image /ImageFile:C:\WinPE\media\sources\boot.wim /MountDir:C:\WinPE\mount /Index:1
  3. Install TightVNC and configure it as a system service. Set a password and change ports if desired (Default = 5900).
  4. Execute the following commands to export the registry keys and files associated with TightVNC.
mkdir C:\VNC
reg export "HKEY_LOCAL_MACHINE\SOFTWARE\TightVNC" C:\VNC\vnc.reg
copy C:\Program Files\TightVNC\*.* C:\VNC\
  1. Download either this repository or the pre-built executables and server.zip found in the releases section and move/extract them to C:\VNC. Ensure there is a separate folder at C:\VNC\server. If downloading the pre-built executables, skip to step 10.
  2. Ensure Node.JS and Python are installed and execute the following commands: // PyInstaller and PKG are used to build the standalone executables found in the releases section, since NodeJS and Python are too bulky to install into WinPE.
pip install PyInstaller
npm install --save @maximegris/node-websockify
npm install pkg
  1. Modify the Python and NodeJS scripts as desired.
  2. From a Command Prompt running as Administrator, execute the following commands to 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
  • 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
  1. Copy C:\VNC to C:\WinPE\mount\Windows. // You can delete the original winpe_httpserver.py and winpe_vnc.js if so desired.
  2. Download NirCMD and place nircmd.exe in C:\WinPE\mount\Windows\System32. // This extends the functionality of Windows commands and will be used for the standalone executables.
  3. Navigate to C:\WinPE\mount\Windows\System32 and open startnet.cmd with Notepad then add and save the following lines: // The nircmd.exe exec hide command essentially runs the standalone executables as a background task to reduce distractions and prevent a Command Prompt from being locked up with either winpe_vnc or winpe_httpserver.
@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
  1. Close all folders/files from C:\WinPE\mount and execute the following command from a Command Prompt as an Administrator to dismount and commit the changes. DISM /Unmount-WIM /MountDir:C:\WinPE\mount /Commit
  2. Once committed, the WinPE installation is ready to be installed onto a USB or HDD of your choice. // Creating a WinPE ISO file and using Rufus is typically the most straight forward approach.

Usage

Once booting into WinPE, the startnet.cmd file will autorun and setup the VNC environment. Locate the IPv4 address found after running the ipconfig command. Access the VNC client via any web browser from a computer on the same network using:

http://[IP ADDRESS]:[PORT (DEFAULT=8000)/#host=[IP ADDRESS]&port=[PORT (DEFAULT=8113)]

A real example would be:

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

And press Connect under the WinPEVNC logo.

FAQ

Q: What is WinPE? A: Windows Preinstallation Environment (WinPE) is a minimal Windows operating system environment designed for troubleshooting and recovery purposes.

Q: Can this be used in a production environment? A: While this project is functional, it's primarily designed for testing and development purposes. Use caution when deploying in production environments.

Q: Are there any security concerns? A: As with any VNC setup, ensure proper firewall configurations and use strong passwords. Consider using SSH tunneling for enhanced security.

Q: How do I troubleshoot connectivity issues? A: Ensure the WinPE machine is connect

Contributing

Contributions are welcome! Please feel free to submit pull requests or issues.

Acknowledgements

Connect With Me

About

WinPE-VNC is a methodology of combining several technologies to properly create establish a VNC connection within WinPE. Available anywhere within a local area network (or external if port forwarding is setup).

Topics

Resources

Stars

Watchers

Forks