uploaded automation scripts
This commit is contained in:
61
closeLDPlayerByName.ps1
Normal file
61
closeLDPlayerByName.ps1
Normal file
@@ -0,0 +1,61 @@
|
||||
#run ldplayer instance
|
||||
param (
|
||||
[string]$instanceName
|
||||
)
|
||||
|
||||
$global:LDPlayerPath ="C:\Ldplayer\LDplayer9"
|
||||
$global:instanceNameglobal=$instanceName
|
||||
function logger($logMessage) {
|
||||
[int]$number = (get-content -path "$global:LDPlayerPath\index_count.txt")
|
||||
if($number -gt 21){ $number=0}
|
||||
$instanceList = Get-Content -Path "$global:LDPlayerPath\instanceList.txt"
|
||||
#$instanceNumber = $instanceList[$number]
|
||||
#$instanceData = (cat C:\Ldplayer\LDplayer9\vms\config\leidian${instanceNumber}.config)
|
||||
#$convertedData = $instanceData | ConvertFrom-Json
|
||||
foreach ( $inst in $instanceList) {
|
||||
$instanceData = (cat C:\Ldplayer\LDplayer9\vms\config\leidian${inst}.config)
|
||||
$convertedData = $instanceData | ConvertFrom-Json
|
||||
$name = $convertedData."statusSettings.playerName"
|
||||
if ($global:instanceNameglobal -eq $name){
|
||||
$count = $inst
|
||||
break
|
||||
}
|
||||
}
|
||||
#if(-not $instanceName){$name = $convertedData."statusSettings.playerName"}
|
||||
#$count = $number+1
|
||||
|
||||
$scriptName = Split-Path -Leaf $PSCommandPath
|
||||
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss.fff"
|
||||
$timestampedLogMessage = $timestamp + " ${global:instanceNameglobal} -instanceID: ${count} -${scriptName} -PID: ${PID}-:" + $logMessage
|
||||
#$timestampedLogMessage
|
||||
$logFilePath = "$global:LDPlayerPath\LDAutoLog.txt"
|
||||
$fs = New-Object System.IO.FileStream($logFilePath, [System.IO.FileMode]::Append, [System.IO.FileAccess]::Write, [System.IO.FileShare]::Read)
|
||||
$sw = New-Object System.IO.StreamWriter($fs)
|
||||
try {
|
||||
$sw.WriteLine($timestampedLogMessage)
|
||||
} finally {
|
||||
$sw.Close()
|
||||
$fs.Close()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$instanceList = Get-Content -Path "$global:LDPlayerPath\instanceList.txt"
|
||||
foreach ( $inst in $instanceList) {
|
||||
$filename = "C:\Ldplayer\LDplayer9\vms\config\leidian${inst}.config"
|
||||
$instanceData = (cat C:\Ldplayer\LDplayer9\vms\config\leidian${inst}.config)
|
||||
$convertedData = $instanceData | ConvertFrom-Json
|
||||
$name = $convertedData."statusSettings.playerName"
|
||||
}
|
||||
|
||||
logger("Closing instance $instanceName")
|
||||
$launchCMD = "ldconsole.exe quit --name $instanceName"
|
||||
$launchCMD | Out-File -FilePath "C:\Ldplayer\Ldplayer9\closeName.txt"
|
||||
|
||||
|
||||
|
||||
<#
|
||||
$number=$number + 1
|
||||
if($number -eq 23){ $number=0}
|
||||
$number | Out-File -FilePath "c:\ldplayer\ldplayer9\index_count.txt"
|
||||
#>
|
||||
Reference in New Issue
Block a user