Function to enable Adobe Flash Player silent automatic update feature
I created the following function to enable the Adobe Flash Player silent automatic update function that was introduced in the recent 11.2 version. KiCHiK's "Replacing Lines in a Text File" example code was very helpful here. I believe you will also need LogicLib.nsh and x64.nsh as includes for this function to work. I tested it with Windows XP (32-Bit) and Windows 7 (64-Bit). Because you are accessing protected system files, you'll need "RequestExecutionLevel" set to "Admin" on Windows 7. I just wanted to share it incase there are other systems administrators that could find it useful. Thanks!
Function SilentAutoUpdateEnable
${If} ${RunningX64}
IfFileExists "$WINDIR\SysWOW64\Macromed\Flash\mms.cfg" 0 CreateMMSFile64
ClearErrors
FileOpen $0 "$WINDIR\SysWOW64\Macromed\Flash\mms.cfg" "r" ; open target file for reading
GetTempFileName $R0 ; get new temp file name
FileOpen $1 $R0 "w" ; open temp file for writing
loop64:
FileRead $0 $2 ; read line from target file
IfErrors done64 ; check if end of file reached
StrCmp $2 "SilentAutoUpdateEnable=0$\r$\n" 0 +2 ; compare line with search string with CR/LF
StrCpy $2 "SilentAutoUpdateEnable=1$\r$\n" ; change line
StrCmp $2 "SilentAutoUpdateEnable=0" 0 +2 ; compare line with search string without CR/LF (at the end of the file)
StrCpy $2 "SilentAutoUpdateEnable=1" ; change line
FileWrite $1 $2 ; write changed or unchanged line to temp file
Goto loop64
done64:
FileClose $0 ; close target file
FileClose $1 ; close temp file
Delete "$WINDIR\SysWOW64\Macromed\Flash\mms.cfg" ; delete target file
CopyFiles /SILENT $R0 "$WINDIR\SysWOW64\Macromed\Flash\mms.cfg" ; copy temp file to target file
Delete $R0 ; delete temp file
Goto Complete64
CreateMMSFile64:
FileOpen $9 "$WINDIR\SysWOW64\Macromed\Flash\mms.cfg" "w" ; creates the file and opens it for write
FileWrite $9 "AutoUpdateDisable=0$\r$\n" ; write the first line
FileWrite $9 "SilentAutoUpdateEnable=1" ; write the last line
FileClose $9 ; closes and saves the file
Complete64:
${Else}
IfFileExists "$WINDIR\system32\Macromed\Flash\mms.cfg" 0 CreateMMSFile32
ClearErrors
FileOpen $0 "$WINDIR\system32\Macromed\Flash\mms.cfg" "r" ; open target file for reading
GetTempFileName $R0 ; get new temp file name
FileOpen $1 $R0 "w" ; open temp file for writing
loop32:
FileRead $0 $2 ; read line from target file
IfErrors done32 ; check if end of file reached
StrCmp $2 "SilentAutoUpdateEnable=0$\r$\n" 0 +2 ; compare line with search string with CR/LF
StrCpy $2 "SilentAutoUpdateEnable=1$\r$\n" ; change line
StrCmp $2 "SilentAutoUpdateEnable=0" 0 +2 ; compare line with search string without CR/LF (at the end of the file)
StrCpy $2 "SilentAutoUpdateEnable=1" ; change line
FileWrite $1 $2 ; write changed or unchanged line to temp file
Goto loop32
done32:
FileClose $0 ; close target file
FileClose $1 ; close temp file
Delete "$WINDIR\system32\Macromed\Flash\mms.cfg" ; delete target file
CopyFiles /SILENT $R0 "$WINDIR\system32\Macromed\Flash\mms.cfg" ; copy temp file to target file
Delete $R0 ; delete temp file
Goto Complete32
CreateMMSFile32:
FileOpen $9 "$WINDIR\system32\Macromed\Flash\mms.cfg" "w" ; creates the file and opens it for write
FileWrite $9 "AutoUpdateDisable=0$\r$\n" ; write the first line
FileWrite $9 "SilentAutoUpdateEnable=1" ; write the last line
FileClose $9 ; closes and saves the file
Complete32:
${EndIf}
FunctionEnd