Announcement

Collapse
No announcement yet.

Function to enable Adobe Flash Player silent automatic update feature

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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!


    code:
    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


  • #2
    You don't need to have the code twice for 32/64. NSIS is 32-bit so will always point to SysWOW64 on 64-bit Windows and System32 on 32-bit Windows when you use $SYSDIR (unless you disable file system redirection using the macro in x64.nsh).

    Stu

    Comment


    • #3
      from my view - code that none needs - as you pointed out to adobe blogs the updater has itself this option.
      and 11.2 is present version. eot
      Greets, Brummelchen

      Comment


      • #4
        Thanks for sharing. But next time please use an attachment or pastebin for something this big.

        Comment


        • #5
          Afrow UK - You're right. The code is redundant. Thanks for the tip.

          Brummelchen - The code allows systems administrators that manage hundreds or thousands of systems to enable this feature automatically. I did not see an option in the native Flash installer to control this feature. The only current methods of enabling the feature, to my knowledge, are via the mms.cfg file and the Flash control panel applet.

          MSG - Thanks for the tip on using an attachment. Will do next time around.


          Thanks for the feedback!

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎