Skip to content

KawaiiSh1zuku/AntsMoving

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AntsMoving - Windows Program Relocation Tool

A Go program that moves Windows applications/directories and automatically fixes registry entries, shortcuts, environment variables, and configuration files pointing to the old location.

ALL codes are vibed!

Features

Core Functionality

  • Move files/directories: Safely relocate programs with automatic rollback on failure
  • Registry scanning & fixing: Finds and updates Windows registry entries pointing to old paths
  • Shortcut repair: Updates .lnk files with new target paths
  • PATH environment updates: Modifies user/system PATH variables
  • Configuration file scanning: Updates config files containing old paths
  • Admin privilege handling: Automatically elevates with UAC prompt when needed

Recent Fixes & Improvements

  • Fixed whitespace handling: Properly escapes paths with spaces during elevation
  • Color support detection: ANSI colors only when terminal supports VT processing
  • Integrated registry backups: Single .reg file instead of multiple files
  • Operation logging: Complete log of all actions in backup directory
  • Debug mode: View PowerShell elevation commands without executing
  • Parallel scanning: Optimized performance with concurrent registry/shortcut scanning

Installation

Prerequisites

  • Go 1.24.0 or higher
  • Windows 10+ (for color support, works on Windows 7+ without colors)

Build from Source

cd AntsMoving
go build -o antsmoving.exe

Dependencies

  • golang.org/x/sys/windows - Windows API access
  • golang.org/x/sys/windows/registry - Registry operations
  • golang.org/x/term - Terminal detection

Usage

Basic Syntax

antsmoving.exe -from <source> -to <destination> [options]

Examples

# Scan for references without making changes
antsmoving.exe -from "D:\OldApp" -to "E:\NewApp" -scan

# Preview changes (dry-run)
antsmoving.exe -from "C:\Program Files\App" -to "D:\Apps\App" -dry-run

# Execute with automatic backup
antsmoving.exe -from "C:\OldPath" -to "C:\NewPath" -backup "C:\Backup"

# Skip confirmation prompts
antsmoving.exe -from "D:\App" -to "E:\App" -yes

# Debug elevation command
antsmoving.exe -from "D:\Nmap" -to "D:\Program Files\Nmap" -debug

Command Line Options

-from string     Source directory or file to move (required)
-to string       Destination directory (required)
-backup string   Backup directory for changed files (default: temp dir)
-silent          Silent mode - minimal output
-dry-run         Preview changes without applying them
-scan            Only scan for references without moving
-yes             Skip confirmation prompts (auto-accept)
-debug           Debug mode: print PowerShell elevation command and exit

How It Works

1. Scanning Phase (Parallel)

  • Registry: Scans common registry locations (HKLM\SOFTWARE, HKCU\SOFTWARE, etc.)
  • Shortcuts: Searches Start Menu, Desktop, and common locations
  • PATH: Checks user and system environment variables
  • Config files: Scans common config file types (.json, .ini, .xml, .yaml, etc.)

2. Backup Phase

  • Registry backup: Creates single registry_backup.reg file
  • Shortcut backup: Copies original .lnk files
  • Operation log: Creates operation.log with complete history

3. Execution Phase

  1. Moves files/directories (with cross-device copy support)
  2. Updates registry entries with new paths
  3. Repairs shortcuts with updated targets
  4. Modifies PATH environment variables
  5. Updates configuration files

4. Rollback (if needed)

  • Restores registry from backup .reg file
  • Restores original shortcuts
  • Moves files back to original location

Technical Details

Color Support Detection

  • Checks NO_COLOR environment variable
  • Verifies terminal supports ANSI colors
  • Windows-specific: Enables ENABLE_VIRTUAL_TERMINAL_PROCESSING console mode
  • Falls back to monochrome output if VT processing not available

Admin Elevation

  • Uses PowerShell Start-Process -Verb RunAs
  • Properly escapes command line arguments with Windows quoting rules
  • Handles paths with spaces correctly (e.g., "D:\Program Files\App")
  • Provides detailed error messages if elevation fails

Registry Scanning Optimization

  • Parallel scanning with worker pool
  • Prioritizes common registry locations
  • Case-insensitive matching
  • 10-minute timeout for deep scans

Log Format

[HH:MM:SS] [LEVEL] Message: Details
  • Colors: Red (ERROR), Yellow (WARN), Green (OK/SUCCESS), Gray (INFO), Blue (DEBUG)
  • File logging: JSON format to antsmoving.log in temp directory
  • Backup logging: Plain text to operation.log in backup directory

Known Limitations

  1. Registry permissions: Some keys may be read-only
  2. Shortcut parsing: Uses PowerShell fallback for LNK file parsing
  3. System PATH: Requires admin privileges for system-wide changes
  4. Running processes: Programs using moved files may need restart
  5. Windows services: Services may need reconfiguration

Testing

Test Scenarios

# Basic functionality
antsmoving.exe -from test_source -to "test dest with spaces" -dry-run

# Admin elevation simulation
antsmoving.exe -from "D:\iMonitor" -to "D:\Program Files\iMonitor" -debug

# Backup functionality
antsmoving.exe -from source -to destination -backup test_backup -scan

License

This project is for educational and practical use. See source code for details.

Contributing

  1. Report issues with detailed error messages and test cases
  2. Include -debug output when reporting elevation problems
  3. Test with -dry-run before actual execution
  4. Backup important data before testing

About

AntsMoving - Windows Program Relocation Tool

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages