CalibreMultiuserStarter/V2/CalibreMultiuserStarterV2.au3.5.bak
2017-09-12 23:14:55 +02:00

78 lines
2.4 KiB
Groff

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=CalibeIcon.ico
#AutoIt3Wrapper_Res_Description=2013 Bernhard Linz / Bernhard@znil.de / http://znil.net
#AutoIt3Wrapper_Res_Fileversion=1.0.0.3
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_LegalCopyright=znil.net
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Dim Const $s_LockFileName = "CalibreLockFile.txt"
Dim Const $s_CalibreProgramName = "calibre-portable.exe"
Dim Const $s_CalibreMainProgramName = "calibre.exe"
Dim $h_lockfile
Dim $h_Calibre
Dim $b_RunCalibe = False
Dim $a_gelockt_von
If FileExists($s_LockFileName) = 1 Then
$h_lockfile = FileOpen($s_LockFileName,0)
$a_gelockt_von = StringSplit(FileReadLine($s_LockFileName), ":", 0)
FileClose($h_lockfile)
; $a_gelockt_von[1] = Benutzername
; $a_gelockt_von[2] = Computername
; $a_gelockt_von[3] = Stunde
; $a_gelockt_von[4] = Minute
; $a_gelockt_von[5] = Tag
; $a_gelockt_von[6] = Monat
; $a_gelockt_von[7] = Jahr
If $a_gelockt_von[0] = 7 Then
MsgBox(262160, "Calibre blockiert", "Der Benutzer '" & $a_gelockt_von[1] & "' am Computer '" & $a_gelockt_von[2] & "'" & @CRLF & _
"hat bereits um " & $a_gelockt_von[3] & ":" & $a_gelockt_von[4] & " Uhr am " & $a_gelockt_von[5] & "." & $a_gelockt_von[6] & "." & $a_gelockt_von[7] & @CRLF & _
"Calibre gestartet und nimmt eventuell Änderungen vor." & @CRLF & @CRLF & _
"Programmaufruf ist blockiert!")
EndIf
$b_RunCalibe = False
Else
$h_lockfile = FileOpen($s_LockFileName,2)
FileWriteLine($h_lockfile, @UserName & ":" & @ComputerName & ":" & @HOUR & ":" & @MIN & ":" & @MDAY & ":" & @MON & ":" & @YEAR & @CRLF)
FileClose($h_lockfile)
$b_RunCalibe = True
EndIf
If $b_RunCalibe = False Then
Exit 1
EndIf
$h_Calibre = Run(@ScriptDir & "\" & $s_CalibreProgramName, @ScriptDir, @SW_MAXIMIZE)
If $h_Calibre = 0 Then
FileDelete($s_LockFileName)
MsgBox(16, "Fehler", "Konnte '" & @ScriptDir & "\" & $s_CalibreProgramName & "' nicht starten")
Exit 1
EndIf
Do
Sleep(3000)
ConsoleWrite($h_Calibre & @CRLF)
If (ProcessExists($h_Calibre) = 0) And (ProcessExists($s_CalibreMainProgramName) = 0) Then
$b_RunCalibe = False
EndIf
Until $b_RunCalibe = False
FileDelete($s_LockFileName)
Sleep (1000)
If FileExists($s_LockFileName) = 1 Then
MsgBox(16,"Warnung", "Konnte das Calibre-Lock-File nicht löschen:" & @CRLF & @ScriptDir & "\" & $s_CalibreProgramName)
Exit 1
Else
Exit 0
EndIf