TeshsTool is a PowerShell script designed to automate the installation of software packages on Windows-based machines. The script utilizes WinForms for the graphical user interface (GUI).
Before using TeshsTool, ensure you meet the following requirements:
- PowerShell 3.0 or later
- Administrative rights to run the program and install packages.
Supported Extensions
- .exe
- .msi
- .reg
- .ps1
- .vbs
The required locations are created automatically and can be customized by modifying these values:
$appIconPath = ".\Assets\AppIcon.ico"
$softwarePath = ".\Software"
$logPath = ".\Logs"
When TeshsTool is first run, it checks for folders named after the software packages you want to install. Inside these folders should be the required installation files.
# Files with names like example.uninstaller.ext will be ignored during installation.
$directoryPath = Join-Path -Path $softwarePath -ChildPath $selectedDirectory.Name
$packages = Get-ChildItem $directoryPath | Where-Object { $_.Extension -match "/*.(exe|msi|reg|ps1|vbs)$" -and $_.Name -notmatch '\.uninstaller\.\w+$' }
The uninstallation process uses existing software locations and checks if the extension is .msi, in which case it can be uninstalled directly. If the extension is different, it searches for a file with the format of example.uninstaller.ext to complete the uninstallation.
# Files without .uninstaller.ext are ignored.
$directoryPath = Join-Path -Path $softwarePath -ChildPath $selectedDirectory.Name
$packages = Get-ChildItem $directoryPath | Where-Object { $_.Extension -match "/*.(msi)$" -or $_.Name -match '\.uninstaller\.\w+$' }
Example templates for creating .uninstaller files to remove different types of programs can be found in the templates folder.
# Path: Templates/sample.uninstaller.ps1
# Locations
$logPath = ".\logs"
# Program to uninstall
$program = "Sample"
# Check if log folder exist if not create it
if (-not (Test-Path -Path $logPath)) {
Write-Verbose "Log directory not found. Creating directory..."
New-Item -Path $logPath -ItemType Directory
}
# Functions
function Save-Log($message) {
$logFile = Join-Path -Path $logPath -ChildPath ("Log_" + (Get-Date -Format "yyyyMMdd_HHmmss") + ".txt")
$logMessage = "$(Get-Date) : $message"
Add-Content -Path $logFile -Value $logMessage
Write-Verbose $logMessage
}
function Remove-Program {
[CmdletBinding(SupportsShouldProcess=$true)]
param([string] $program)
if($PSCmdlet.ShouldProcess($program, 'Uninstall')) {
Get-CimInstance -Class Win32_Product | Where-Object { $_.Name -eq $program } | Invoke-CimMethod -MethodName "Uninstall"
Write-Verbose "Removing $program"
}
}
try {
Remove-Program -program $program -Verbose -ErrorAction SilentlyContinue
}
catch {
Save-Log $_.Exception.Message
}
-
Ensure you have the software inside the software folder and that its extension is supported.
-
Open a PowerShell terminal as an administrator.
-
Navigate to the directory where the project is cloned.
-
In the terminal, type the following command to run the program:
.\TeshsTool.ps1
-
Select desired software individually or select all.
-
Click "Install" to begin installation or "Uninstall" to remove software.
-
Ensure you have the software inside the software folder and that its extension is supported.
-
Run the teshstool.exe as an administrator.
-
Select desired software individually or select all.
-
Click "Install" to begin installation or press "Uninstall" to remove software.
You can make any necessary changes to the existing teshstool.ps1 script. Once you are satisfied with the changes, run the rebuildteshstool.bat as an administrator to compile an executable.
.\RebuildTeshsTool.bat
Logs are stored in the logs folder, and a message will appear when a log is created. All logs are created and stored by date and time.
function Save-Log($package, $message) {
$logFile = Join-Path -Path $logPath -ChildPath ("Log_" + (Get-Date -Format "yyyyMMdd_HHmmss") + ".txt")
$logMessage = "$(Get-Date) - $($package.FullName): $message"
Add-Content -Path $logFile -Value $logMessage
Write-Verbose $logMessage
}
This script is provided as-is and without any warranty. The author shall not be liable for any damages or losses arising from the use of this script. Use at your own risk.
This script is licensed under the MIT license. See the LICENSE file for more information.