- NSIS Discussion
- simple installer with MUI2 - some questions
Archive: simple installer with MUI2 - some questions
Zamorro
1st June 2011 21:54 UTC
simple installer with MUI2 - some questions
Hallo togehter, i'm new with NSIS
How to show a different text for titel and message in uninstaller page then in installer page
by using MUI or MUI2?
my current script
;Include Modern UI
!include "MUI2.nsh"
;--------------------------------
;General
;Name and file
Name "Install Alice and change GTAIV version7 into version4"
OutFile "Install-Alice.exe"
;Default installation folder
InstallDir "C:\Program Files\Rockstar Games\Grand Theft Auto IV"
;Get installation folder from registry if available
InstallDirRegKey HKCU "Grand Theft Auto IV" ""
;Request application privileges for Windows Vista
RequestExecutionLevel user
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
;--------------------------------
;Pages
!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Installer Sections
Section "Dummy Section" SecDummy
SetOutPath "$INSTDIR"
File testtesttest.txt
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall-Alice.exe"
SectionEnd
;--------------------------------
;Descriptions
;Language strings
LangString DESC_SecDummy ${LANG_ENGLISH} "A test section."
;Assign language strings to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
;Uninstaller Section
Section "Uninstall"
Delete "$INSTDIR\testtesttest.txt"
Delete "$INSTDIR\Uninstall-Alice.exe"
SectionEnd
MSG
2nd June 2011 06:16 UTC
1) I don't think the GTA4 regkeys will be in HKCU, because it installs to program files which requires admin access. Admin installers (should) write to HKLM. If it IS stored in HKCU, then it will be the admin's HKCU, so either way you need to elevate your installer. Use requestexecutionlevel admin and use the UserInfo plugin in .onInit to verify admin access.
2) What text do you want to change? The "Install Alice and change GTAIV version7 into version4" title? You can't do that (easily). You should instead use a better name, like "Alice GTAIV downgrader", and then put the longer "Install Alice and etc etc" as the component description.
3) In the future please use pastebin or an attachment to share large pieces of code.
Zamorro
3rd June 2011 07:54 UTC
Thanks for fast reply, i left the MUI and made it now with default nsis ui as slim as possible
my current script: alice install script / test
I want to allow the user to backup by uninstalling his custom files which he added
so i added a MessageBox MB_YESNO with following commands by true:
CreateDirectory $DESKTOP\Alice
CopyFiles $INSTDIR\Alice\*.* $DESKTOP\Alice
basicly it works but the Alice folder is unvisible on my Desktop
i can find it by using a file manager
and if the $INSTDIR\Alice folder contains more than 10 files it works as it should
is my system buggy or what's wrong?
off topic: how can i edit my submitted post?
-----------
edit
i found now the edit icon for this post but not for my previous post
MSG
3rd June 2011 15:07 UTC
Sounds like a caching problem. Tried F5 on your desktop?
Zamorro
3rd June 2011 16:45 UTC
Originally posted by MSG
Sounds like a caching problem. Tried F5 on your desktop?
oh, yes, F5 helped to show it
what's now the problem? my system or the uninstaller?
maybe i should backup the files in $DOCUMENTS
MSG
3rd June 2011 18:52 UTC
Originally posted by Zamorro
oh, yes, F5 helped to show it
what's now the problem? my system or the uninstaller?
maybe i should backup the files in $DOCUMENTS
$docs would probably be a better choice, yeah. As for the caching issue... No idea, really. Try a second system and see if you can reproduce the problem.
Zamorro
3rd June 2011 20:31 UTC
Originally posted by MSG
Try a second system and see if you can reproduce the problem.
that's an idea but when it happens on my system then it can also happen on another users system
$docs would probably be a better choice, yeah. As for the caching issue... No idea, really.
$docs ? or $DOCS ? the compiler doesn't accept it and it isn't written in the user manual
is there a newer version than 2.46?
My next problem is to check by uninstalling if the Alice folder contains files
using wildcard
IfFileExists $INSTDIR\Alice\*.* ask
the unistaller choose allways
ask no matter if there are files or if the folder is empty
Section "uninstall"
IfFileExists $INSTDIR\Backup\GTAIV-V7.exe next
MessageBox MB_OK "GTAIV-V7.exe was not found in Backup folder"
Quit
next:
IfFileExists $INSTDIR\Alice\*.* ask
Goto restore
ask:
MessageBox MB_YESNO "do you want to backup the Alice scripts?" IDYES true IDNO false
true:
DetailPrint "Alice scripts are saved at My Documents\Alice"
CreateDirectory "$DOCUMENTS\Alice"
CopyFiles $INSTDIR\Alice\*.* $DOCUMENTS\Alice
Goto restore
false:
DetailPrint "All Alice scripts have been deleted"
restore:
Rename $INSTDIR\Backup\GTAIV-V7.exe $INSTDIR\GTAIV.exe
Delete "$INSTDIR\testtesttest.txt"
Delete "$INSTDIR\uninstall-Alice.exe"
RMDir /r /REBOOTOK "$INSTDIR\Alice"
RMDir /r /REBOOTOK "$INSTDIR\Backup"
SectionEnd
MSG
3rd June 2011 20:37 UTC
Originally posted by Zamorro
$docs ? or $DOCS ?
I was referring to the $DOCUMENTS variable.
Originally posted by Zamorro
IfFileExists $INSTDIR\Alice\*.* ask
the unistaller choose allways ask no matter if there are files or if the folder is empty
That's because an empty subdirectory always contains . (current dir) and .. (parent dir). If the directory exists, dir\*.* will also exist.
Zamorro
3rd June 2011 21:47 UTC
Originally posted by MSG
That's because an empty subdirectory always contains . (current dir) and .. (parent dir). If the directory exists, dir\*.* will also exist.
shit, is there any method to check if the folder is empty?
is it possible to get the filesize of an folder?
Zamorro
4th June 2011 06:14 UTC
Originally posted by Yathosho
http://nsis.sourceforge.net/Check_if_dir_is_empty
Thank you, that's cool and works fine
I first found another method and want to discuss it just because of interest
It requires
!include "FileFunc.nsh"
${GetSize} "$INSTDIR\Alice" "/S=0M" $0 $1 $2
IfErrors 0 +3
MessageBox MB_OK "error"
Goto skip
StrCmp $0 0 0 +3
MessageBox MB_OK "Directory is NOT empty"
Goto skip
MessageBox MB_OK "Directory is empty"
skip:
the code works as it should, if filesize $0 = 0 shows the MessageBox "Directory is empty"
then i thought i could check for the amount of available files with $1
StrCmp $1 0 0 +3
but that won't work correct
it shows allways the MessageBox "Directory is empty"
Am i totally wrong or didn't i understand the StrCmp?
T.Slappy
4th June 2011 06:56 UTC
String are really hard comparable :)
Some time ago there were some problems, but now they should be fixed.
Anyway, try to use "" for strings: StrCmp $1 "0" 0 +3
Zamorro
4th June 2011 14:09 UTC
Originally posted by T.Slappy
String are really hard comparable :)
Some time ago there were some problems, but now they should be fixed.
Anyway, try to use "" for strings: StrCmp $1 "0" 0 +3
No, it also won't work, but anyway, i'll use the
isEmptyDir function
As last i want to check if there are *.asi files in $INSTDIR and found the
Locate_plugin
I studied the LocateTest.nsi and ripped the neccesary part for my current LocateAsifiles.nsi:
Name "Locate asi files"
OutFile LocateAsi.exe
!include "Locate.nsh"
Section
GetTempFileName $1
FileOpen $2 $1 w
${locate::Open} "$PROGRAMFILES\Rockstar Games\Grand Theft Auto IV" "/F=1 /D=0 /M=*.asi /B=1" $R0
StrCmp $R0 0 0 loop
Quit
loop:
${locate::Find} $R0 $R1 $R2 $R3 $R4 $R5 $R6
StrCmp $R1 '' close
StrCmp $R4 '' 0 +3
FileWrite $2 'DIR:"$R1" [Created: $R5] [$R6]$\r$\n'
goto +2
FileWrite $2 '$R1 $\r$\n'
goto loop
close:
${locate::Close} $R0
${locate::Unload}
FileClose $2
Exec '"notepad.exe" "$1"'
SectionEnd
my question now, what should do this line?
FileWrite $2 'DIR:"$R1" [Created: $R5] [$R6]$\r$\n'
it looks like it should list empty files with DIR: in the beginning of the line
but i couldn't imitate such a case
i added a folder with name mist.asi and an empty textfile and renamed it as test.asi
the folder was never listed and the empty file was allways listed without Dir: in the beginning
Afrow UK
7th June 2011 10:02 UTC
Your assumption is wrong! That example is simply writing to a temp file (GetTempFileName) and then opening it afterwards (Exec notepad.exe). If you want to find out what is going on, how about running it! Also never stick a loop in a Section. The progress bar will jump back and forth and this heavily degrades code performance. You should move the code to a function and call that.
Stu
Zamorro
10th June 2011 13:04 UTC
Originally posted by Afrow UK
Your assumption is wrong! That example is simply writing to a temp file (GetTempFileName) and then opening it afterwards (Exec notepad.exe). If you want to find out what is going on, how about running it! Also never stick a loop in a Section. The progress bar will jump back and forth and this heavily degrades code performance. You should move the code to a function and call that.
Stu
I removed the FileWrite lines and added Rename $R1 $DOCUMENTS\AliceUninstfiles\$R3
Thank YOUUU all
I finished my script:
Installing Alice and GTAIV-downgrade to GTAIV v5
Is it allowed to give here the link to download Alice-Installer.exe?