Archive
Archive for February, 2010
How to automate nightly updates of a Kiosk PowerPoint
2010/02/27
Leave a comment
This copies nightly a ppt file from a network share where it is collaboratively edite to a network computer where it is displayed for announcement and marketing. The ppt file should already be set to kiosk, manual timings, loop mode.
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=\\adfileprod01\Shared\LLC\scheduling\channel55-presenter\updater-channel55.exe
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
; revision after hardware upgrade from hallway.au3, "hallway"->"channel55" not in variable names, only in strings , except for encryption password
; includes debugging
; connect to channel55-presenter using tightvnc
; adapt at [TBA]
#include <ie.au3>; put the compiled executable of this in channel55Presenter c:\temp and run it as a scheduled task late-nightly
#include <debug.au3>
#include <File.au3>
#include <Screencapture.au3>
#include <String.au3>
#include <Date.au3>
Global $filename = "[TBA]"; "channel55"
Global $filenamelog = "[TBA]"; "channel55"
Global $fileextremote = ".pps"
Global $fileextlocal = ".pps"
Global $fileextlog = ".log"
Global $pathfilelog
Global $filepathlocal = "[TBA]"; "c:\temp\"
Global $fileshareordriveremote = "[TBA]"; "\\resman\Student Saved Work\"
Global $filepathremote = "[TBA]"; "Admin\conf\scheduling\channel55-presenter\"
Global $filepathremotebackup = "tmp\"
Global $usernameinstructor = "[TBA]" ; "trplagwitz"
Global $passwordinstructor = "[TBA]" ; hashed password
Global $passworddecrypt = "hallway"
Global $LogonDomain = "[TBA]" ; "ad.loyola.edu"
Global $timelocal
Global $timeremote
Global $debugtype = "debugconsole"
_ScreenCapture_SetBMPFormat(0)
$logfilehandle = FileOpen($fileshareordriveremote & $filepathremote & $filepathremotebackup & $filename & $fileextlog, 1)
If Not FileExists($fileshareordriveremote & $filepathremote & $filename & $fileextremote) Then
$ret = FileWriteLine($logfilehandle, "cannot open file: " & $fileshareordriveremote & $filepathremote & $filename & $fileextremote)
FileClose($logfilehandle)
Exit
Else
If ProcessExists("powerpnt.exe") Then
ProcessClose("powerpnt.exe")
EndIf
Sleep(5000)
If ProcessExists("powerpnt.exe") Then
$ret3 = RunWait('taskkill /F /fi "imagename eq powerpnt*" /im *')
EndIf
Sleep(2000)
$ret = FileCopy($fileshareordriveremote & $filepathremote & $filename & $fileextremote, $filepathlocal & $filename & $fileextlocal, 1)
$ret = FileWriteLine($logfilehandle, "result:" & $ret & " filemove from: " & $fileshareordriveremote & $filepathremote & $filepathremotebackup & $filename & "_" & today() & $fileextlocal & "t: " & $filepathlocal & $filename & $fileextlocal)
If FileExists($fileshareordriveremote & $filepathremote & $filename & $fileextremote) Then
FileDelete($fileshareordriveremote & $filepathremote & $filename & $fileextremote)
EndIf
ShellExecute($filepathlocal & $filename & $fileextlocal)
EndIf
FileClose($logfilehandle)
Exit
Func today()
Return (@YEAR & @MDAY & @MON)
EndFunc ;==>today
Func addHallwayPresenterNetworkshares($LogonDomain)
If $LogonDomain = "" Then $LogonDomain = @LogonDomain
If StringLen($passworddecrypt) > 0 Then
$driveletterreplacementforhallwayread = DriveMapAdd("*", $fileshareordriveremote, 0, $LogonDomain & "\" & $usernameinstructor, _StringEncrypt(0, $passwordinstructor, $passworddecrypt))
Else
$driveletterreplacementforhallwayread = DriveMapAdd("*", $fileshareordriveremote, 0, $LogonDomain & "\" & $usernameinstructor, $passwordinstructor)
EndIf
myDebugOut(@ScriptLineNumber, "$driveletterreplacementforhallwayread is: " & $driveletterreplacementforhallwayread & ", $fileshareordriveremote is " & $fileshareordriveremote & ", $usernameinstructor, $passwordinstructor are " & $usernameinstructor & $passwordinstructor)
If (($driveletterreplacementforhallwayread == "") Or $driveletterreplacementforhallwayread == 0) Then
$driveletterreplacementforhallwayread = "H:"
EndIf
Return $driveletterreplacementforhallwayread
EndFunc ;==>addHallwayPresenterNetworkshares
Func removeHallwayPresenterNetworkShares()
$driveletterreplacementforhallwayread = $fileshareordriveremote
If StringInStr($driveletterreplacementforhallwayread, ":") Then
If StringInStr($driveletterreplacementforhallwayread, "\") Then
StringTrimRight($driveletterreplacementforhallwayread, 1)
EndIf
$ret = DriveMapDel($driveletterreplacementforhallwayread)
If $ret = 0 Then myDebugOut(@ScriptLineNumber, "failed to DriveMapDel for: " & $driveletterreplacementforhallwayread)
EndIf
EndFunc ;==>removeHallwayPresenterNetworkShares
Func myDebugOut($ScriptLineNumber = @ScriptLineNumber, $msg = "Error")
Local $debugstring
Local $debugfilename
Local $tabhandle
Local $tabmaxnumber
Local $tempdir
$tempdir = @TempDir
If $tempdir == "" Then $tempdir = "c:\temp"
$debugstring = $ScriptLineNumber & "~" & _Now() & "~" & $msg
If $debugtype = "debug" Then
Local $activewindowtitle = WinGetTitle("")
MsgBox(0, "debug", $debugstring)
WinActivate($activewindowtitle)
ElseIf $debugtype = "debugconsole" Then
ConsoleWrite($debugstring & Chr(13))
ElseIf $debugtype = "run" Then
If $tempdir == "" Then $tempdir = "c:\temp"
$debugfilename = FileNameEscape($debugstring, $tempdir) & ".jpg"
_ScreenCapture_Capture($debugfilename)
_DebugOut($debugstring)
ElseIf $debugtype = "debugconsolescreen" Then
ConsoleWrite($debugstring & Chr(13))
$debugfilename = FileNameEscape($debugstring, $tempdir) & ".jpg"
_ScreenCapture_Capture($debugfilename)
ElseIf $debugtype = "releasetextlog" Then
If $pathfilelog == "" Then $pathfilelog = @TempDir & "\" & "autoitlogfile.log"
$loghandle = FileOpen($pathfilelog, 1)
If $ret = 0 Or @error Then Exit
$ret = FileWriteLine($loghandle, $debugstring & Chr(13))
If $ret = 0 Or @error Then Exit
$ret = FileClose($loghandle)
ElseIf $debugtype = "releasewordpad" Then
Else
SetError(1)
EndIf
EndFunc ;==>myDebugOut
Func FileNameEscape($filename, $tempdir)
$filename = StringReplace($filename, ":", "_")
$filename = StringReplace($filename, ">", "larger_than")
$filename = StringReplace($filename, "<", "smaller_than")
$filename = StringReplace($filename, " ", "_")
$filename = StringReplace($filename, "/", "&")
$filename = StringReplace($filename, "/", "+")
$filename = StringReplace($filename, "&", "+")
$filename = StringReplace($filename, Chr(9), "_")
$filename = StringReplace($filename, "?", "questionmark")
$filename = StringReplace($filename, "!", "exclamationmark")
$filename = StringReplace($filename, "'", "quotationmark")
$filename = StringReplace($filename, Chr(34), "doublequotationmark")
$filename = StringReplace($filename, "__", "_")
$filename = StringReplace($filename, "__", "_")
$filename = StringReplace($filename, "__", "_")
$filename = StringReplace($filename, "__", "_")
$filename = $tempdir & "\" & $filename
Return $filename
EndFunc ;==>FileNameEscape
Func FileCopy2LocalTemp($filepath)
Dim $arrfilepath, $filepathname, $arrfilepathname, $filepathnameext
$blnValid = True
If Not FileExists($filepath) Then
If Not DriveMapAdd("", $filepath) Then
$blnValid = False
EndIf
EndIf
If $blnValid Then
$arrfilepath = StringSplit($filepath, "\")
If @error Then
SetError(1)
myDebugOut(@ScriptLineNumber, "error stringsplit filepath")
EndIf
$filepathname = $arrfilepath(UBound($arrfilepath) - 1)
$ret = FileCopy($filepath, @TempDir & "\" & $filepathname)
Else
SetError(1)
EndIf
EndFunc ;==>FileCopy2LocalTemp

