- AVS
- NSIS Script Example?? (WA2.*, WA3)
Archive: NSIS Script Example?? (WA2.*, WA3)
greatWho
11th August 2002 21:34 UTC
NSIS Script Example?? (WA2.*, WA3)
Looks that Winamp 3 will be the main for now... so there are many diffrent things:
WA2.*:
-AVS is in the Folder Winamp\Plugins\AVS\
-AVS Config is in the Winamp.ini
WA3 :
-AVS is in the folder Winamp3\Wacs\data\avs
-AVS Config is in the Studio.ini
has anyone already a script, that will check if WA2.* or WA* is installed (if both versions are installed, the user will be asked where he wants to install:WA2.*, WA3 or both) and so the presets will be installed to the right place?
maybe a Close and Open WA2.* or WA3??
if you have, it would be nice, if you would post it here..
thanx
GreatWho
Yathosho
11th August 2002 23:09 UTC
i tried this and it's quite complex. i'm already at 3k of code just to check for winamp and it doesnt yet work.
the yet most efficient solution seems to be writing a function (which i work on atm) or a message-dialog at the very beginning of the installer.
Yathosho
12th August 2002 09:55 UTC
i posted this in the nsis forums
EL-VIS2
12th August 2002 11:39 UTC
Using uninstall Reg Key!
The following is just a first try on this and not tested completely since I don't have winamp3 installed yet. It seems to work with my winamp2 installation. I do not know if I've got the correct regkey for winamp3. It is just a guess. Perhaps anybody knows if right!
----------------------------------------
InstallDir $PROGRAMFILES\WINAMP
Function .onInit
StrCpy $4 "Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" ;UninstallRegKey for winamp2
StrCpy $5 "Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp3" ;UninstallRegKey for winamp3 (just a guess)
; loading regkey of winamp2 into $1
ReadRegStr $1 HKLM \
$4 \
"UninstallString"
;loading regkey of winamp3 into $2
ReadRegStr $2 HKLM \
$5 \
"UninstallString"
StrCmp $1 "" nowa2 wa2 ; ckecking for winamp2
nowa2: ; no winamp2 found
StrCmp $2 "" nowa30 wa30 ; ckecking for winamp3
nowa30: ; no regkey found at all
StrCpy $3 ""
Goto ready
wa30: ; winamp3 found
StrCpy $3 $5
Goto ready
wa2: ; winamp2 found
StrCmp $2 "" nowa31 wa31 ; checking for winamp3
nowa31: ; no winamp3 found
StrCpy $3 $4
Goto ready
wa31: ; both versions found
MessageBox MB_YESNO "It seems you've got Winamp2 AND Winamp3 on your system. Install into Winamp3?. (NO will install into Winamp2)" IDYES winamp2
StrCpy $3 $5
Goto ready
winamp2:
StrCpy $3 $4
Goto ready
ready:
FunctionEND
InstallDirRegKey HKLM \
$3 \
"UninstallString"
Function .onVerifyInstDir
IfFileExists $INSTDIR\winamp.exe Good
IfFileExists $INSTDIR\studio.exe Good
MessageBox MB_YESNO "It seems that the current directory does not contain winamp. Continue installing?" IDYES Good
Abort
Good:
FunctionEnd
Yathosho
12th August 2002 12:29 UTC
i put together something similiar, querying the registry. it's the safest way to check that winamp is installed (or not). since the code is quite long and complex (goto-commands are way old-fashioned and should be avoided).
i got the following idea how to solve this. i'm sharing myself, so if someone else is faster than me, he/she can build it upon my idea.
querying the registry on both versions seems to unavoidable, although unelegant. once the version(s) is (are) determined, one can write a string that defines the name of the .ini file (winamp.ini / studio.ini). the plugins directory can still be determined using GetPluginsDir.
most certainly i'll come with a solution within the next two days.
EL-VIS2
12th August 2002 12:36 UTC
More complete now
Worked out a setup for the different install paths of winmap2 and winamp3 and if no winamp is found:
Function .onVerifyInstDir
IfFileExists $INSTDIR\winamp.exe winamp2
IfFileExists $INSTDIR\studio.exe winamp3
MessageBox MB_YESNO "It seems that the current directory does not contain winamp. Continue installing?" IDYES nowinamp
Abort
nowinamp:
StrCpy $6 "AVS"
Goto install
winamp2:
StrCpy $6 "PLUGINS\AVS"
Goto install
winamp3:
StrCpy $6 "WACS\DATA\AVS"
Goto install
install:
FunctionEnd
SetOverwrite on
Section "Install MYAVS"
SetOutPath "$INSTDIR\$6\MYAVS"
File "C:\PROGRAMME\WINAMP\PLUGINS\AVS\MYAVS\*.avs"
SectionEnd
EL-VIS2
12th August 2002 13:15 UTC
FORGET IT
Forget my first try. Now tested it but it doesn't work since InstallDirRegKey seems to be called before oninit function :(
Yathosho
12th August 2002 14:19 UTC
good work, elvis
EL-VIS2
12th August 2002 14:40 UTC
Now working
Now this should work with the latest NSIS version. I've tested it with winamp3 and winamp2 and it worked fine. Any suggestions for improvements?
InstallDir "$PROGRAMFILES\WINAMP\"
Function .onInit
; loading regkey of winamp2 into $1
ReadRegStr $1 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" \
"UninstallString"
;loading regkey of winamp3 into $2
ReadRegStr $2 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp3" \
"UninstallString"
StrCmp $1 "" nowa2 wa2 ; ckecking for winamp2
nowa2: ; no winamp2 found
StrCmp $2 "" nowa30 wa30 ; ckecking for winamp3
nowa30: ; no regkey found at all
;DO NOTHING
Goto ready
wa30: ; winamp3 found
StrCpy $INSTDIR $2
Call StripPath
Goto ready
wa2: ; winamp2 found
StrCmp $2 "" nowa31 wa31 ; checking for winamp3
nowa31: ; no winamp3 found
StrCpy $INSTDIR $1
Call StripPath
Goto ready
wa31: ; both versions found
MessageBox MB_YESNO "It seems you've got Winamp2 AND Winamp3 on your system. Install into Winamp3?. (NO will install into Winamp2)" IDNO winamp2
StrCpy $INSTDIR $2
Call StripPath
Goto ready
winamp2:
StrCpy $INSTDIR $1
Call StripPath
Goto ready
ready:
FunctionEND
Function StripPath
Push $1
Push $2
StrCmp $INSTDIR "" fin
StrCpy $1 $INSTDIR 1 0 ; get firstchar
StrCmp $1 '"' "" getparent
; if first char is ", let's remove "'s first.
StrCpy $INSTDIR $INSTDIR "" 1
StrCpy $1 0
rqloop:
StrCpy $2 $INSTDIR 1 $1
StrCmp $2 '"' rqdone
StrCmp $2 "" rqdone
IntOp $1 $1 + 1
Goto rqloop
rqdone:
StrCpy $INSTDIR $INSTDIR $1
getparent:
; the uninstall string goes to an EXE, let's get the directory.
StrCpy $1 -1
gploop:
StrCpy $2 $INSTDIR 1 $1
StrCmp $2 "" gpexit
StrCmp $2 "\" gpexit
IntOp $1 $1 - 1
Goto gploop
gpexit:
StrCpy $INSTDIR $INSTDIR $1
fin:
Pop $2
Pop $1
FunctionEnd
Function .onVerifyInstDir
IfFileExists $INSTDIR\Winamp.exe winamp2
IfFileExists $INSTDIR\Studio.exe winamp3
MessageBox MB_YESNO "It seems that the current directory does not contain winamp. Continue installing?" IDYES nowinamp
Abort
nowinamp:
StrCpy $6 "AVS"
Goto install
winamp2:
StrCpy $6 "PLUGINS\AVS"
Goto install
winamp3:
StrCpy $6 "WACS\DATA\AVS"
Goto install
install:
FunctionEnd
SetOverwrite on
Section "Install MYAVS"
SetOutPath "$INSTDIR\$6\MYAVS"
File "C:\PROGRAMME\WINAMP\PLUGINS\AVS\MYAVS\*.avs"
SectionEnd
greatWho
12th August 2002 19:58 UTC
thanx for script
it works fine....
surprised to read from you after your goodbye @ deviantart
how have you made the "Autostart AVS on Play" in your History-Pack?
and how can i make that the install-prog close automaticaly?
thanx
GreatWho
greatWho
12th August 2002 21:12 UTC
entry in *.ini
how can i write configs in the ini?
example:
if winamp2.*:
$INSTDIR\winamp.ini AVS cfg_fs_rnd 1
if Winamp3 :
$INSTDIR\studio.ini cfg_fs_rnd 1
Winamp3 has no winamp.ini... is it Winampa.ini??
----
how to autostart on play?
and how can i restart winamp? (the one where the pack is installed)
thanx
GreatWho
greatWho
12th August 2002 22:03 UTC
ok, i found the solution to restart Winamp
Winamp2:
Exec "$INSTDIR\winamp.exe"
Winamp3:
Exec "$INSTDIR\studio.exe"
because Winamp2 is installed in ..\Programfiles\Winamp\ and Winamp3 in ..\programfiles\Winamp3\ there is only one version in $INSTDIR, and so the right Winamp will restart
but how can i configure the ini? if it would not exist, it would create and the ini wouldn't be used...
greatWho
12th August 2002 22:29 UTC
i also found the solution for config *.ini
like the $6 in the script from el-vis, i made
nowinamp:
STRCPY $7 "AVS"
Goto install
winamp2:
StrCpy $7 "$INSTDIR\Winamp.ini"
Goto install
winamp3:
StrCpy $7 "$INSTDIR\Studio.ini"
and configure:
WriteINIStr $7 AVS cfg_fs_rnd 1
look my full script:
; The name of the installer
Name "MYAVS"
; The file to write
OutFile "MYAVS.exe"
;-----------------------------------------------
; CloseWinamp
; Closes all running instances of Winamp 1.x/2.x
; modifies no other variables
;
Section -CloseWinamp
Call CloseWinamp
SectionEnd
Function CloseWinamp
Push $0
loop:
FindWindow $0 "Winamp v1.x"
IntCmp $0 0 done
SendMessage $0 16 0 0
Sleep 100
Goto loop
done:
Pop $0
FunctionEnd
;
; Close running Winamp 3
;
Section -CloseWinamp3
Call CloseWinamp3
SectionEnd
Function CloseWinamp3
Push $0
loop:
FindWindow $0 "STUDIO"
IntCmp $0 0 done
SendMessage $0 16 0 0
Sleep 100
Goto loop
done:
Pop $0
FunctionEnd
;
;--------------------------------------------------
;
;
; Version check
;
;
InstallDir "$PROGRAMFILES\WINAMP\"
Function .onInit
; loading regkey of winamp2 into $1
ReadRegStr $1 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" \
"UninstallString"
;loading regkey of winamp3 into $2
ReadRegStr $2 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp3" \
"UninstallString"
StrCmp $1 "" nowa2 wa2 ; ckecking for winamp2
nowa2: ; no winamp2 found
StrCmp $2 "" nowa30 wa30 ; ckecking for winamp3
nowa30: ; no regkey found at all
;DO NOTHING
Goto ready
wa30: ; winamp3 found
StrCpy $INSTDIR $2
Call StripPath
Goto ready
wa2: ; winamp2 found
StrCmp $2 "" nowa31 wa31 ; checking for winamp3
nowa31: ; no winamp3 found
StrCpy $INSTDIR $1
Call StripPath
Goto ready
wa31: ; both versions found
MessageBox MB_YESNO "It seems you've got Winamp2 AND Winamp3 on your system. Install into Winamp3?. (NO will install into Winamp2)" IDNO winamp2
StrCpy $INSTDIR $2
Call StripPath
Goto ready
winamp2:
StrCpy $INSTDIR $1
Call StripPath
Goto ready
ready:
FunctionEND
Function StripPath
Push $1
Push $2
StrCmp $INSTDIR "" fin
StrCpy $1 $INSTDIR 1 0 ; get firstchar
StrCmp $1 '"' "" getparent
; if first char is ", let's remove "'s first.
StrCpy $INSTDIR $INSTDIR "" 1
StrCpy $1 0
rqloop:
StrCpy $2 $INSTDIR 1 $1
StrCmp $2 '"' rqdone
StrCmp $2 "" rqdone
IntOp $1 $1 + 1
Goto rqloop
rqdone:
StrCpy $INSTDIR $INSTDIR $1
getparent:
; the uninstall string goes to an EXE, let's get the directory.
StrCpy $1 -1
gploop:
StrCpy $2 $INSTDIR 1 $1
StrCmp $2 "" gpexit
StrCmp $2 "\" gpexit
IntOp $1 $1 - 1
Goto gploop
gpexit:
StrCpy $INSTDIR $INSTDIR $1
fin:
Pop $2
Pop $1
FunctionEnd
Function .onVerifyInstDir
IfFileExists $INSTDIR\Winamp.exe winamp2
IfFileExists $INSTDIR\Studio.exe winamp3
MessageBox MB_YESNO "It seems that the current directory does not contain winamp. Continue installing?" IDYES nowinamp
Abort
nowinamp:
StrCpy $6 "AVS"
STRCPY $7 "AVS"
Goto install
winamp2:
StrCpy $6 "PLUGINS\AVS"
StrCpy $7 "$INSTDIR\Winamp.ini"
Goto install
winamp3:
StrCpy $6 "WACS\DATA\AVS"
StrCpy $7 "$INSTDIR\Studio.ini"
Goto install
install:
FunctionEnd
;
;----------------------------------------------------------------------------
;
SetOverwrite on
;
;
;------------------------------------------------------------------------------
;
;MessageBox
;
Section "Message"
MessageBox MB_OK "'TITEL ' (c) Copyright by Patrik Neunteufel aka GreatWho for comments or questions contact me @ Great.Who@gmx.ch i would like to read your opinion if you want to use something for your own preset, pleas ask and send me your preset thanx...... Have a viewing pleasure"
SectionEnd
;
;------------------------------------------------------------------------------
;
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
;
InstallDirRegKey HKLM SOFTWARE\MYAVS "Install_Dir"
;
;------------------------------------------------------------------------------
;
;install part
;
;------------------------------------------------------------------------------
;
;
; The text to prompt the user to enter a directory
;
ComponentText "This will install MYAVS on your computer. Select which optional things you want installed."
;
; The text to prompt the user to enter a directory
DirText "Choose a directory to install in to:"
;
;********* the stuff to install *************
;****first section (the presetpack)******
;
Section "Install MYAVS"
;
;----Set Out Dir
;
SetOutPath "$INSTDIR\$6\MYAVS"
;
;----put files there
;
File "C:\PROGRAMME\WINAMP\PLUGINS\AVS\MYAVS\*.*"
;
;----Write the installation path into the registry
;
WriteRegStr HKLM SOFTWARE\MYAVS "Install_Dir" "$INSTDIR"
;
;----Write the uninstall keys for Windows
;
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MYAVS" "DisplayName" "MYAVS (remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MYAVS" "UninstallString" '"$INSTDIR\uninstallMYAVS.exe"'
WriteUninstaller "uninstallMYAVS.exe"
;
SectionEnd
;
;*****second section (APE Install)******
;
;
Section "Various APE (any Presets may require)"
;
;----set out Dir
;
SetOutPath "$INSTDIR\$6\"
;
;---.put files there
;
File "C:\Programme\winamp\plugins\avs\*.ape"
;
;----Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\APE" "DisplayName" "APE (remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\APE" "UninstallString" '"$INSTDIR\uninstallAPE.exe"'
WriteUninstaller "uninstallAPE.exe"
;
SectionEnd
;
;******third section (start menue shortcut)**********
;
Section "Start Menu Shortcuts"
;
CreateDirectory "$SMPROGRAMS\MYAVS"
CreateShortCut "$SMPROGRAMS\MYAVS\UninstallMYAVS.lnk" "$INSTDIR\uninstallMYAVS.exe" "" "$INSTDIR\uninstallMYAVS.exe" 0
;
SectionEnd
;
;******fourth section (exclulive part) *************
;
Section "Exclusive"
;
SetOutPath "c:\GreatWho_exclusive"
;
;---.put files there
;
File "C:\Programme\winamp\plugins\avs\ex\*.*"
;
SectionEnd
;
;******set AVS as actual Vis_Plugin*******
;
Section "Set AVS as actual PlugIn"
WriteINIStr $7 Winamp visplugin_name vis_avs.dll
SectionEnd
;
;
;******set actual presetPack******
;
Section "Set MYAVS as actual Presetpack"
WriteINIStr $7 AVS config_pres_subdir "MYAVS"
SectionEnd
;
;
;*******set random******
;
Section "Set Random-mode"
WriteINIStr $7 AVS cfg_fs_rnd 1
WriteINIStr $7 AVS cfg_fs_rnd_time 25
SectionEnd
;
;*******set Fullscreen******
;
Section "Fullscreen settings"
WriteINIStr $7 AVS cfg_fs_w 320
WriteINIStr $7 AVS cfg_fs_h 200
WriteINIStr $7 AVS cfg_fs_use_overlay 1
SectionEnd
;
;****autostart AVS******
;
Section "Autostart AVS on play"
WriteINIStr $7 Winamp visplugin_autoexec 1
SectionEnd
;
;******Exclusive Play*****
;
Section "ExclusivePlay"
Exec '"$INSTDIR\winamp.exe" c:\GreatWho_exclusive\ex.m3u'
Exec '"$INSTDIR\studio.exe" c:\GreatWho_exclusive\ex.m3u'
SectionEnd
;
;
;************uninstall stuff****************
;
UninstallText "This will uninstall MYAVS. Hit next to continue."
;
;----special uninstall section.
;
Section "Uninstall"
;
;---remove registry keys
;
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MYAVS"
DeleteRegKey HKLM SOFTWARE\MYAVS
;
;---remove files
;
Delete $INSTDIR\$6\MYAVS\*.*
;
;---MUST REMOVE UNINSTALLER, too
;
Delete $INSTDIR\uninstallMYAVS.exe
;
;---remove shortcuts, if any.
;
Delete "$SMPROGRAMS\MYAVS\*.*"
;
;---remove directories used.
;
RMDir "$SMPROGRAMS\MYAVS"
RMDir "$INSTDIR\$6\MYAVS"
SectionEnd
;
;
u can use if u want
GreatWho
EL-VIS2
13th August 2002 10:14 UTC
Basic Script
Here's my basic AVS-NSIS script:
- checking for winamp verions and giving choice if both are found
- verifying install path and giving warning if no winamp is found
- uninstaller
- link to uninstall exe
- running winamp
I did no reg-entries and no ini-changes. If you need to refer to GreatWhos' scripting.
Rovastar
13th August 2002 17:54 UTC
Personally I beleive that it is 'bad form' to force the NSIS installer to have autoexec plug-in on play there.
The are loads of tech support question saying how do I stop the visuals playing every single play and some plug-in/avs pack writers as adding to this problem with this.
I like my visuals as much as the next man but on playing every file.:eek:
EL-VIS2
14th August 2002 13:12 UTC
AVS-INI-Changes
I also don't like to mess with AVS-INI entries. And I don't like anyone to mess with mine. I know some people don't know how to run AVS-presets and to force AVS to run may be helpful for them but I think a better and safer way is to display a text- or html-file with some instructions...
UnConeD
14th August 2002 13:32 UTC
I think the best way is to allow the user to choose everything himself.
The only thing I do in my installer is:
- Set currently loaded preset to my Intro preset (replace the 'vis_avs.dat' file in the same dir as the AVS DLL with the preset you want).
- Set AVS as default plug-in (can be turned off).
The first doesn't really do any harm, because it's just a temporary file from AVS anyway.
The second makes it easier for people to watch the presets, if they use many plug-ins. They just installed AVS presets, so it's safe to assume they'll want to open AVS now.
Yathosho
14th August 2002 19:56 UTC
greatWho: i take that copyright message as a joke. :down:
EL-VIS2
15th August 2002 09:52 UTC
VIS_AVS.DAT
The problem with changing vis_avs.dat is, that if the presets does not work allright and crashes avs/winamp the user will be unable to start avs or even winmap again until vis_avs.dat is removed manually.
This happened to some users with my PLASMA pack where I used an AVI in vis_avs.dat which crashes avs/winamp on some systems....
So make shure the preset you put into vis_avs.dat is a "simple" one which will run for shure everywhere....
Also your vis_avs.dat perhaps will not work correct with future versions of AVS....
jheriko
4th September 2002 04:30 UTC
Originally posted by UnConeD
I think the best way is to allow the user to choose everything himself.
Like the install directory? I have 4 installs of winamp for varying purposes, your installers for whacko iv and v always install to the wrong one :(
besides am i the only one who thinks that the message box approach to choosing winamp 2 and 3 looks really unprofessional and well... sort of like a skatchy hack?