1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 16:45:07 +00:00

fix(windows): bypass installer execution policy

Refs #612
This commit is contained in:
Tw93
2026-03-21 19:19:57 +08:00
parent 746bb2c956
commit 982aa6ecb2
4 changed files with 30 additions and 14 deletions

View File

@@ -59,10 +59,10 @@ git clone --branch windows https://github.com/tw93/Mole.git $installDir
cd $installDir
# Run the installer in place (keeps .git for mo update)
.\install.ps1 -InstallDir $installDir -AddToPath
powershell -ExecutionPolicy Bypass -File .\install.ps1 -InstallDir $installDir -AddToPath
# Optional: Create Start Menu shortcut
.\install.ps1 -InstallDir $installDir -AddToPath -CreateShortcut
powershell -ExecutionPolicy Bypass -File .\install.ps1 -InstallDir $installDir -AddToPath -CreateShortcut
```
Run:
@@ -280,10 +280,10 @@ Custom scan paths can be configured with `mo purge --paths`.
```powershell
# Install to custom location from a cloned windows branch
.\install.ps1 -InstallDir C:\Tools\Mole -AddToPath
powershell -ExecutionPolicy Bypass -File .\install.ps1 -InstallDir C:\Tools\Mole -AddToPath
# Create Start Menu shortcut
.\install.ps1 -InstallDir C:\Tools\Mole -AddToPath -CreateShortcut
powershell -ExecutionPolicy Bypass -File .\install.ps1 -InstallDir C:\Tools\Mole -AddToPath -CreateShortcut
# Refresh the source channel later
mo update
@@ -292,7 +292,7 @@ mo update
### Uninstall
```powershell
.\install.ps1 -Uninstall
powershell -ExecutionPolicy Bypass -File .\install.ps1 -Uninstall
```
## Configuration

View File

@@ -370,7 +370,7 @@ Expand-Archive release/mole-1.0.0-x64.zip -DestinationPath test-install
# Test installation
cd test-install/mole-1.0.0-x64
.\install.ps1
powershell -ExecutionPolicy Bypass -File .\install.ps1
# Verify mole works
mole --version

View File

@@ -98,7 +98,7 @@ function Show-InstallerHelp {
$c = $script:Colors
Write-Host " $($c.Green)USAGE:$($c.NC)"
Write-Host ""
Write-Host " .\install.ps1 [options]"
Write-Host " powershell -ExecutionPolicy Bypass -File .\install.ps1 [options]"
Write-Host ""
Write-Host " $($c.Green)OPTIONS:$($c.NC)"
Write-Host ""
@@ -118,19 +118,19 @@ function Show-InstallerHelp {
Write-Host " $($c.Green)EXAMPLES:$($c.NC)"
Write-Host ""
Write-Host " $($c.Gray)# Install with defaults$($c.NC)"
Write-Host " .\install.ps1"
Write-Host " powershell -ExecutionPolicy Bypass -File .\install.ps1"
Write-Host ""
Write-Host " $($c.Gray)# Install and add to PATH$($c.NC)"
Write-Host " .\install.ps1 -AddToPath"
Write-Host " powershell -ExecutionPolicy Bypass -File .\install.ps1 -AddToPath"
Write-Host ""
Write-Host " $($c.Gray)# Custom install location$($c.NC)"
Write-Host " .\install.ps1 -InstallDir C:\Tools\Mole -AddToPath"
Write-Host " powershell -ExecutionPolicy Bypass -File .\install.ps1 -InstallDir C:\Tools\Mole -AddToPath"
Write-Host ""
Write-Host " $($c.Gray)# Full installation$($c.NC)"
Write-Host " .\install.ps1 -AddToPath -CreateShortcut"
Write-Host " powershell -ExecutionPolicy Bypass -File .\install.ps1 -AddToPath -CreateShortcut"
Write-Host ""
Write-Host " $($c.Gray)# Uninstall$($c.NC)"
Write-Host " .\install.ps1 -Uninstall"
Write-Host " powershell -ExecutionPolicy Bypass -File .\install.ps1 -Uninstall"
Write-Host ""
}
@@ -403,7 +403,7 @@ powershell.exe -ExecutionPolicy Bypass -NoLogo -NoProfile -Command "& '%MOLE_DIR
Write-Host " & `"$InstallDir\mole.ps1`""
Write-Host ""
Write-Host " Or add to PATH with:"
Write-Host " .\install.ps1 -AddToPath"
Write-Host " powershell -ExecutionPolicy Bypass -File .\install.ps1 -AddToPath"
}
Write-Host ""

View File

@@ -80,6 +80,18 @@ function Invoke-GitCommand {
}
}
function Get-PowerShellCommand {
if (Get-Command powershell.exe -ErrorAction SilentlyContinue) {
return "powershell.exe"
}
if (Get-Command pwsh -ErrorAction SilentlyContinue) {
return "pwsh"
}
throw "PowerShell executable not found"
}
# Main installation
try {
Write-Host ""
@@ -150,7 +162,11 @@ try {
Write-Step "Running installer..."
Write-Host ""
& (Join-Path $InstallDir "install.ps1") -InstallDir $InstallDir -AddToPath
$powerShellCommand = Get-PowerShellCommand
& $powerShellCommand -NoLogo -NoProfile -ExecutionPolicy Bypass -File (Join-Path $InstallDir "install.ps1") -InstallDir $InstallDir -AddToPath
if ($LASTEXITCODE -ne 0) {
throw "Installer exited with code $LASTEXITCODE"
}
Write-Host ""
Write-Success "Installation complete!"