From 4cb53f4594ff8bcfd211d1c2a310a0842c343dbc Mon Sep 17 00:00:00 2001 From: harryeetsource <95581121+harryeetsource@users.noreply.github.com> Date: Tue, 4 Mar 2025 16:46:09 -0800 Subject: [PATCH] Update and rename install-driver.txt to install-driver.ps1 --- install-driver.ps1 | 44 ++++++++++++++++++++++++++++++++++++++++++++ install-driver.txt | 1 - 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 install-driver.ps1 delete mode 100644 install-driver.txt diff --git a/install-driver.ps1 b/install-driver.ps1 new file mode 100644 index 0000000..0d5f8ae --- /dev/null +++ b/install-driver.ps1 @@ -0,0 +1,44 @@ +# Ensure the script is running with administrative privileges. +if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) +{ + Write-Error "This script must be run as Administrator." + exit 1 +} + +# Set the path to your INF file (update this path as needed) +$InfPath = "C:\path\to\shadow.inf" +$InfFullPath = Resolve-Path $InfPath + +Write-Output "Installing INF from: $InfFullPath" + +# Construct and run the rundll32 command to install the INF using the DefaultInstall.NTamd64 section +$rundllCmd = "rundll32.exe setupapi,InstallHinfSection DefaultInstall.NTamd64 132 `"$InfFullPath`"" +Write-Output "Executing: $rundllCmd" +Invoke-Expression $rundllCmd + +# Pause briefly to allow the INF installation to complete +Start-Sleep -Seconds 5 + +# Search for the driver file (shadow.sys) in the DriverStore\FileRepository +$DriverStorePath = "C:\Windows\System32\DriverStore\FileRepository" +$shadowSys = Get-ChildItem -Path $DriverStorePath -Recurse -Filter "shadow.sys" -ErrorAction SilentlyContinue | Select-Object -First 1 + +if ($null -eq $shadowSys) { + Write-Error "shadow.sys not found in DriverStore\FileRepository." + exit 1 +} + +$DriverFilePath = $shadowSys.FullName +Write-Output "Driver file found at: $DriverFilePath" + +# Create the service using sc.exe +$ServiceName = "shadow" +# Wrap the path in quotes (note the backticks for proper escaping in the command line) +$binPath = "`"$DriverFilePath`"" +$scCommand = "sc.exe create $ServiceName type= kernel binPath= $binPath start= demand" +Write-Output "Executing: $scCommand" +Invoke-Expression $scCommand + +# Query the service to verify it was created +Write-Output "Querying service $ServiceName:" +sc.exe query $ServiceName diff --git a/install-driver.txt b/install-driver.txt deleted file mode 100644 index 12a9566..0000000 --- a/install-driver.txt +++ /dev/null @@ -1 +0,0 @@ -rundll32.exe setupapi,InstallHinfSection DefaultInstall.NTamd64 132 C:\path\to\shadow.inf