uploaded automation scripts
This commit is contained in:
38
closeLdplayer.ps1
Normal file
38
closeLdplayer.ps1
Normal file
@@ -0,0 +1,38 @@
|
||||
#close LDPlayer
|
||||
|
||||
$global:LDPlayerPath ="C:\Ldplayer\LDplayer9"
|
||||
|
||||
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-1]
|
||||
$instanceData = (cat C:\Ldplayer\LDplayer9\vms\config\leidian${instanceNumber}.config)
|
||||
$convertedData = $instanceData | ConvertFrom-Json
|
||||
$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 + "-$name, ($count/22)-$scriptName-PID: ${PID}-:" + $logMessage
|
||||
$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()
|
||||
}
|
||||
}
|
||||
|
||||
[int]$number = (get-content -path "c:\ldplayer\ldplayer9\index_count.txt")
|
||||
$instanceList = Get-Content -Path "$global:LDPlayerPath\instanceList.txt"
|
||||
$instanceNumber = $instanceList[$number-1]
|
||||
$instanceData = (cat C:\Ldplayer\LDplayer9\vms\config\leidian${instanceNumber}.config)
|
||||
$convertedData = $instanceData | ConvertFrom-Json
|
||||
$name = $convertedData."statusSettings.playerName"
|
||||
$count = $number+1
|
||||
logger("Closing instance $instanceNumber, $name, ($count/22)")
|
||||
$launchCMD = "ldconsole.exe quit --index $instanceNumber"
|
||||
$launchCMD | Out-File -FilePath "C:\Ldplayer\Ldplayer9\closeNow.txt"
|
||||
Reference in New Issue
Block a user