• Web sitemizin içeriğine ve tüm hizmetlerimize erişim sağlamak için Web sitemize kayıt olmalı ya da giriş yapmalısınız. Web sitemize üye olmak tamamen ücretsizdir.

Multi Kombat Betik Çalıştırıcısı v1.0

TRWE_2012

لِيَغْفِرَ لَكَ اللّٰهُ مَا تَقَدَّمَ مِنْ ذَنْبِك
Moderatör
Konum
BERTUNA
Forum Yaşı
6 Yıl 2 Ay
Mesajlar
5,479
Tepkime puanı
17,170


Tüm Betik Formatlarını Tek Bir Yerde Çalıştıran PS1 Betiği [Kodsal Tasarım : TRWE_2012]


Merhabalar

Kısa Konu Anlatımı :

1.Yedi ayrı .bat çalıştırıcısını tek, uzantıya göre otomatik yönlenen bir .ps1 betiği...

2.Betik hem doğrudan bir yol argümanıyla (Universal-Script-Runner.ps1 "C:\...\script.py" — kısayola sürükle-bırak için ideal) hem de argümansız çalıştırılıp yol sorularak kullanılabilir.

3.Dosya uzantısına (.bat, .cmd, .ps1, .py, .vbs, .vbe, .exe, .lnk) bakıp otomatik olarak doğru çalıştırma mekanizmasını seçebiliyor. (akıllı betik bu)

4.Desteklenmeyen bir uzantı verilirse (örn. .txt), açıkça hangi türlerin desteklendiğini söyleyen bir hata veriyor.

5.Python kontrolü eklendi.Yani sisteminizde Python yüklü olup olmadığına bakıyor.

Ekran Görüntüsü :

Zuwnlmj.png

KOD İÇERİĞİ : Universal-Script-Runner.ps1

Kod:
# ============================================================
# Universal Script Runner
# Consolidated from: Universal BAT/CMD/PS1/Python/VBS/EXE/LNK Runner.bat
# System : Windows 11
#
# Detects the file type by extension and automatically runs it with the
# correct mechanism. Supports: .bat .cmd .ps1 .py .vbs .vbe .exe .lnk
#
# USAGE:
#   Run with a path argument:  Universal-Script-Runner.ps1 "C:\path\script.ps1"
#   Or run with no argument to be prompted for a path.
#
# NOTE ON .lnk: The original .bat's comment called this a "symlink runner",
# but a .lnk file is a Windows SHORTCUT, not a true filesystem symlink.
# Real NTFS symlinks (created via mklink) have no special extension - the
# OS already follows them transparently, so no special handling is needed
# for those; they just work with any normal file operation.
# ============================================================

param(
    [string]$Path
)

# --- GET THE FILE PATH ---
if ([string]::IsNullOrWhiteSpace($Path)) {
    $Path = Read-Host "Enter the full path of the file to run"
}

# Strip surrounding quotes, in case the user pasted a quoted path
$Path = $Path.Trim('"')

# --- CHECK IF THE FILE EXISTS ---
if (-not (Test-Path -LiteralPath $Path -PathType Leaf)) {
    Write-Host "Error: The specified file was not found!" -ForegroundColor Red
    Write-Host "Path checked: $Path" -ForegroundColor Red
    Read-Host "`nPress ENTER to exit."
    exit 1
}

$extension = [System.IO.Path]::GetExtension($Path).ToLower()

# --- DISPATCH BASED ON FILE EXTENSION ---
switch ($extension) {

    { $_ -in '.bat', '.cmd' } {
        Write-Host "Running batch/cmd script: $Path" -ForegroundColor Cyan
        & cmd.exe /c "`"$Path`""
    }

    '.ps1' {
        Write-Host "Running PowerShell script: $Path" -ForegroundColor Cyan
        & powershell.exe -NoProfile -ExecutionPolicy Bypass -File $Path
    }

    '.py' {
        if (-not (Get-Command python -ErrorAction SilentlyContinue)) {
            Write-Host "Error: Python was not found on this system (not in PATH)." -ForegroundColor Red
        } else {
            Write-Host "Running Python script: $Path" -ForegroundColor Cyan
            & python $Path
        }
    }

    { $_ -in '.vbs', '.vbe' } {
        Write-Host "Running VBScript: $Path" -ForegroundColor Cyan
        & cscript.exe //nologo $Path
    }

    '.exe' {
        Write-Host "Running EXE file: $Path" -ForegroundColor Cyan
        Start-Process -FilePath $Path
    }

    '.lnk' {
        Write-Host "Running shortcut: $Path" -ForegroundColor Cyan
        Start-Process -FilePath $Path
    }

    default {
        Write-Host "Error: Unsupported file type '$extension'." -ForegroundColor Red
        Write-Host "Supported types: .bat .cmd .ps1 .py .vbs .vbe .exe .lnk" -ForegroundColor Yellow
        Read-Host "`nPress ENTER to exit."
        exit 1
    }
}

Write-Host ""
Write-Host "Operation completed." -ForegroundColor Green
Read-Host "`nPress ENTER to exit."

Güle güle kullanın...
 
Geri
Üst