Skip to content

Add RunWIMUtil.cmd Script to Simplify WIMUtil Execution #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions RunWIMUtil.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
@echo off
setlocal EnableDelayedExpansion

:: RunWIMUtil.cmd
:: Author: ZeroDot1 (https://github.com/ZeroDot1)
:: Purpose: Runs WIMUtil PowerShell script from https://github.com/memstechtips/WIMUtil
:: Created: May 12, 2025

:: Check if running as Administrator
echo Checking for administrator privileges...
net session >nul 2>&1
if %errorLevel% neq 0 (
echo This script must be run as Administrator.
echo Right-click the script and select "Run as administrator".
pause
exit /b 1
)

:: Verify PowerShell is available
echo Checking for PowerShell...
powershell -Command "Get-Host" >nul 2>&1
if %errorLevel% neq 0 (
echo Error: PowerShell is not installed or not accessible.
pause
exit /b 1
)

:: Set PowerShell execution policy to Unrestricted
echo Setting PowerShell execution policy to Unrestricted...
powershell -Command "Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy Unrestricted -Force" >nul 2>&1
if %errorLevel% neq 0 (
echo Error: Failed to set PowerShell execution policy.
pause
exit /b 1
)

:: Display WIMUtil version (latest release from GitHub)
echo Retrieving WIMUtil version...
for /f "tokens=2 delims=:" %%a in ('curl -s https://api.github.com/repos/memstechtips/WIMUtil/releases/latest ^| find "tag_name"') do (
set "WIMUTIL_VERSION=%%a"
set "WIMUTIL_VERSION=!WIMUTIL_VERSION:~2,-2!"
)
if "!WIMUTIL_VERSION!"=="" (
echo Warning: Could not retrieve WIMUtil version. Check internet connection or GitHub API access.
) else (
echo WIMUtil Version: !WIMUTIL_VERSION!
)

:: Run WIMUtil PowerShell script
echo Launching WIMUtil...
powershell -NoProfile -Command "irm 'https://github.com/memstechtips/WIMUtil/raw/main/src/WIMUtil.ps1' | iex"
if %errorLevel% neq 0 (
echo Error: Failed to run WIMUtil. Check internet connection or GitHub repository.
pause
exit /b 1
)

echo WIMUtil execution completed. Follow the wizard instructions in the PowerShell window.
pause
exit /b 0