Initial commit (1.0.0)
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
param (
|
||||
[string]$Action
|
||||
)
|
||||
|
||||
# Default values for the service
|
||||
$ServicePath = ".\SoraV2Utils_Service.exe"
|
||||
$ServiceName = "SoraV2Utils_Service"
|
||||
$Description = "SoraV2 Utils Service"
|
||||
$DisplayName = "SoraV2 Utils Service"
|
||||
|
||||
# Function to install the service
|
||||
function Install-Service {
|
||||
param (
|
||||
[string]$ServicePath,
|
||||
[string]$ServiceName,
|
||||
[string]$Description,
|
||||
[string]$DisplayName
|
||||
)
|
||||
|
||||
$FullServicePath = (Resolve-Path -Path $ServicePath).Path
|
||||
|
||||
New-Service -Name $ServiceName -BinaryPathName $FullServicePath -Description $Description -DisplayName $DisplayName -StartupType Automatic
|
||||
|
||||
Write-Host "Service '$ServiceName' installed successfully."
|
||||
}
|
||||
|
||||
# Function to remove the service
|
||||
function Remove-Service {
|
||||
param (
|
||||
[string]$ServiceName
|
||||
)
|
||||
|
||||
Stop-Service -Name $ServiceName -Force
|
||||
sc.exe delete $ServiceName
|
||||
|
||||
Write-Host "Service '$ServiceName' removed successfully."
|
||||
}
|
||||
|
||||
# Function to start the service
|
||||
function Start-Service {
|
||||
param (
|
||||
[string]$ServiceName
|
||||
)
|
||||
|
||||
Start-Service -Name $ServiceName
|
||||
|
||||
Write-Host "Service '$ServiceName' started successfully."
|
||||
}
|
||||
|
||||
# Function to stop the service
|
||||
function Stop-Service {
|
||||
param (
|
||||
[string]$ServiceName
|
||||
)
|
||||
|
||||
Stop-Service -Name $ServiceName
|
||||
|
||||
Write-Host "Service '$ServiceName' stopped successfully."
|
||||
}
|
||||
|
||||
# Function to get the status of the service
|
||||
function Get-ServiceStatus {
|
||||
param (
|
||||
[string]$ServiceName
|
||||
)
|
||||
|
||||
$Service = Get-Service -Name $ServiceName
|
||||
Write-Host "Service '$ServiceName' is $($Service.Status)."
|
||||
}
|
||||
|
||||
# Main script logic
|
||||
switch ($Action.ToLower()) {
|
||||
"install" {
|
||||
Install-Service -ServicePath $ServicePath -ServiceName $ServiceName -Description $Description -DisplayName $DisplayName
|
||||
break
|
||||
}
|
||||
"remove" {
|
||||
Remove-Service -ServiceName $ServiceName
|
||||
break
|
||||
}
|
||||
"start" {
|
||||
Start-Service -ServiceName $ServiceName
|
||||
break
|
||||
}
|
||||
"stop" {
|
||||
Stop-Service -ServiceName $ServiceName
|
||||
break
|
||||
}
|
||||
"status" {
|
||||
Get-ServiceStatus -ServiceName $ServiceName
|
||||
break
|
||||
}
|
||||
default {
|
||||
Write-Host "Usage: .\Install-Service.ps1 -Action <install|remove|start|stop|status>"
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
param (
|
||||
[string]$version
|
||||
)
|
||||
|
||||
# Function to replace version in a file
|
||||
function Replace-Version {
|
||||
param (
|
||||
[string]$filePath,
|
||||
[string]$regexPattern,
|
||||
[string]$replacement
|
||||
)
|
||||
|
||||
if (Test-Path $filePath) {
|
||||
(Get-Content $filePath) -replace $regexPattern, $replacement | Set-Content $filePath
|
||||
Write-Host "Updated $filePath"
|
||||
} else {
|
||||
Write-Host "File not found: $filePath"
|
||||
}
|
||||
}
|
||||
|
||||
# Update SoraV2BatteryHelperSetup.vdproj
|
||||
$vdprojFile = "SoraV2BatteryHelperSetup\SoraV2BatteryHelperSetup.vdproj"
|
||||
$vdprojPattern = '(\s*)"ProductVersion" = "8:\d+\.\d+\.\d+"'
|
||||
$vdprojReplacement = '$1"ProductVersion" = "8:' + $version + '"'
|
||||
Replace-Version -filePath $vdprojFile -regexPattern $vdprojPattern -replacement $vdprojReplacement
|
||||
|
||||
# Update AssemblyInfo.cs files
|
||||
$assemblyFiles = @(
|
||||
"SoraV2BatteryHelperSvc\Properties\AssemblyInfo.cs",
|
||||
"SoraV2BatteryHelperNotification\Properties\AssemblyInfo.cs"
|
||||
)
|
||||
|
||||
$assemblyVersionPattern = '(\s*)\[assembly: AssemblyVersion\("(\d+\.\d+\.\d+\.\d+)"\)\]'
|
||||
$assemblyFileVersionPattern = '(\s*)\[assembly: AssemblyFileVersion\("(\d+\.\d+\.\d+\.\d+)"\)\]'
|
||||
$assemblyVersionReplacement = '$1[assembly: AssemblyVersion("' + $version + '")]'
|
||||
$assemblyFileVersionReplacement = '$1[assembly: AssemblyFileVersion("' + $version + '")]'
|
||||
|
||||
foreach ($assemblyFile in $assemblyFiles) {
|
||||
Replace-Version -filePath $assemblyFile -regexPattern $assemblyVersionPattern -replacement $assemblyVersionReplacement
|
||||
Replace-Version -filePath $assemblyFile -regexPattern $assemblyFileVersionPattern -replacement $assemblyFileVersionReplacement
|
||||
}
|
||||
Reference in New Issue
Block a user