Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 6th April 2012, 21:12   #1
Rapport12
Junior Member
 
Join Date: Feb 2012
Posts: 3
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

Rapport12 is offline   Reply With Quote
Old 6th April 2012, 21:59   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 7th April 2012, 00:56   #3
Brummelchen
Major Dude
 
Join Date: May 2003
Posts: 681
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
http://www.adobe.com/products/flashp...ribution3.html
Brummelchen is offline   Reply With Quote
Old 7th April 2012, 06:42   #4
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
Thanks for sharing. But next time please use an attachment or pastebin for something this big.
MSG is offline   Reply With Quote
Old 9th April 2012, 16:55   #5
Rapport12
Junior Member
 
Join Date: Feb 2012
Posts: 3
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!
Rapport12 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
adobe, automatic, flash, silent, update

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump