Skip to content

Instantly share code, notes, and snippets.

<#!
.SYNOPSIS
Decrypts original level files for the DOS PC game Bolo by Dongleware.
.DESCRIPTION
Writes each decrypted level beside the input as <name>.decrypted.txt.
By default, processes LEVEL* files with no extension in this script's folder.
Decoded bytes are interpreted as DOS code page 850 text and written as UTF-8 without BOM.
DISCLAIMER: This script is an unofficial community utility and is not provided, endorsed, or supported by Dongleware.
<#!
.SYNOPSIS
Patches a SCORE.BO file for the DOS PC game Bolo by Dongleware to unlock training mode.
.DESCRIPTION
Updates one SCORE.BO record with a caller-supplied name and score, then recomputes the 16-bit checksum expected by the DOS executable.
To unlock training mode, set the score to >= 50000.
DISCLAIMER: This script is an unofficial community utility and is not provided, endorsed, or supported by Dongleware.
It is provided for educational purposes only.
@zett42
zett42 / BuildShowArgsExe.ps1
Created April 16, 2025 10:32
Simple PowerShell script to build a C# console application that prints all arguments
# Builds a C# console application that prints all arguments (requires Windows PowerShell 5.1)
Add-Type -OutputType ConsoleApplication -OutputAssembly ShowArgs.exe -TypeDefinition @'
using System;
namespace MyApp
{
class Program
{
static int Main( string[] args )
@zett42
zett42 / ConsoleControlHandlerDemo.ps1
Last active March 19, 2025 12:24
PowerShell Console Control Handler Demo (using script block)
$ErrorActionPreference = 'Stop'
# Compile the cmdlet and import it as a module
Add-Type -TypeDefinition (Get-Content $PSScriptRoot\PSConsoleCtrlHandler.cs -Raw) -PassThru | Import-Module -Assembly { $_.Assembly }
# Add the handler
Add-ConsoleCtrlHandler {
param( [ConsoleCtrlEvent] $ctrlType )
$logPath = (New-Item $env:temp\_MyPS\console.log -Force).Fullname
@zett42
zett42 / PowerShellConsoleCtrlHandlerDemo.ps1
Created March 18, 2025 18:54
PowerShell Console Control Handler Demo (SetConsoleCtrlHandler)
Add-Type -TypeDefinition @'
using System;
using System.IO;
using System.Runtime.InteropServices;
public class ConsoleHelper {
[DllImport("Kernel32")]
private static extern bool SetConsoleCtrlHandler(HandlerRoutine handler, bool add);
private delegate bool HandlerRoutine(int ctrlType);
@zett42
zett42 / SelfElevate.ps1
Last active January 9, 2025 19:18
Self-Elevate PowerShell script
# PowerShell demo to self-elevate a script
# - Makes sure parameters are properly forwarded to the elevated script (preserving argument types and spaces in string arguments).
# - Passes the current directory to elevated script.
param(
[string] $Foo,
[int] $Bar
)
# Self-elevate the script if required
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
@zett42
zett42 / Bundle Snippet.wxs
Last active October 10, 2024 10:19
Customize a Wix v5 theme with automatic localization
<BootstrapperApplication>
<bal:WixStandardBootstrapperApplication
Theme="rtfLargeLicense"
ThemeFile="Theme.xml"
LicenseFile="1033\License.rtf"
LocalizationFile="1033\thm.wxl"
LogoFile="logo.png"
ShowVersion="yes"
/>
@zett42
zett42 / EditConsoleInput.ps1
Last active April 25, 2024 22:02
Edit PowerShell console input in external editor
#---------------------------------------------------------------------------------------------------------------
# Defines keyboard shortcut Alt+E for the console to edit current input in VSCode
# (edit the line that starts with "code" to use another editor).
#
# This code is an extension of this StackOverflow answer:
# https://stackoverflow.com/a/71175083/7571258
#
# New features:
# - Saves/restores the current cursor position (if the text hasn't changed too much).
# - Passes the current cursor position to VSCode, so the editors cursor gets positioned as in the console.
@zett42
zett42 / FalloutHackerMinigame.ps1
Last active July 16, 2023 08:54
Guess the password - minigame inspired by Fallout
<#
.SYNOPSIS
A PowerShell game inspired by the Fallout hacking minigame.
.DESCRIPTION
This is a PowerShell game inspired by the Fallout hacking minigame.
The game is played by guessing the password of a computer terminal.
The player has a limited number of attempts to guess the password.
After each guess, the game will display the number of correct letters.
The player can use this information to narrow down the list of possible passwords.
The game has multiple difficulty levels. The higher the level, the longer the passwords to guess become.
@zett42
zett42 / WatchWindowOpened.ps1
Last active June 19, 2023 16:08
Listen to WindowOpenedEvent using UI automation in PowerShell with inline C#
# Windows PowerShell (5.1) script
# Watch top-level window creation and log window name, process ID and process name.
Add-Type -ReferencedAssemblies UIAutomationClient, UIAutomationTypes -TypeDef @'
using System;
using System.Windows.Automation;
public class WindowWatcher
{
public static void Watch()