Old 28th June 2018, 11:59   #1
luca89ct
Junior Member
 
Join Date: Jun 2018
Posts: 8
Errors on uninstall section

Hi to everyone!

In my $INSTDIR I have a file "file.txt" with 2 lines (12/14). I have a cycle on my script that for each line in file, create a new folder with this code:
code:
Section -MainProgram
${INSTALL_TYPE}
SetOverwrite ifnewer
SetOutPath "$INSTDIR"
File "C:\Users\Gare\Source\Workspaces\etagent-i4u\bin\Debug\ETAgentI4U_setup.exe"
File "C:\Users\Gare\Source\Workspaces\etagent-i4u\bin\Debug\ETAgentI4U_setup.exe.config"
ExecWait '"$INSTDIR\ETAgentI4U_setup.exe"'

FileOpen $0 $INSTDIR\file.txt r
LOOP:
ClearErrors
FileRead $0 $1
${If} $1 <> ""
SetOutPath "$INSTDIR\$1"
File "C:\Users\Gare\Source\Workspaces\etagent-i4u\bin\Debug\App.config"
File "C:\Users\Gare\Source\Workspaces\etagent-i4u\bin\Debug\config.ini"
File "C:\Users\Gare\Source\Workspaces\etagent-i4u\bin\Debug\data.dat"
File "C:\Users\Gare\Source\Workspaces\etagent-i4u\bin\Debug\ETAgentI4U.exe"
File "C:\Users\Gare\Source\Workspaces\etagent-i4u\bin\Debug\ETAgentI4U.exe.config"
File "C:\Users\Gare\Source\Workspaces\etagent-i4u\bin\Debug\Install.bat"
File "C:\Users\Gare\Source\Workspaces\etagent-i4u\bin\Debug\NLog.config"
File "C:\Users\Gare\Source\Workspaces\etagent-i4u\bin\Debug\NLog.dll"
File "C:\Users\Gare\Source\Workspaces\etagent-i4u\bin\Debug\NLog.xml"
File "C:\Users\Gare\Source\Workspaces\etagent-i4u\bin\Debug\RestSharp.dll"
File "C:\Users\Gare\Source\Workspaces\etagent-i4u\bin\Debug\RestSharp.xml"
SetOutPath "$INSTDIR\$1\logs"
${EndIf}
IfErrors +1 LOOP
FileClose $0

SectionEnd



During Install no problem. But when I have to uninstall it, it remove "$INSTDIR\12\logs" and "$INSTDIR\14\logs" folders but not other files. Could you please help me to find the problem? Here my uninstall script:
code:
Section Uninstall
${INSTALL_TYPE}

FileOpen $0 $INSTDIR\file.txt r
LOOP:
ClearErrors
FileRead $0 $1
${If} $1 <> ""


Delete "$INSTDIR\$1\App.config"
Delete "$INSTDIR\$1\config.ini"
Delete "$INSTDIR\$1\data.dat"
Delete "$INSTDIR\$1\ETAgentI4U.exe"
Delete "$INSTDIR\$1\ETAgentI4U.exe.config"
Delete "$INSTDIR\$1\Install.bat"
Delete "$INSTDIR\$1\NLog.config"
Delete "$INSTDIR\$1\NLog.dll"
Delete "$INSTDIR\$1\NLog.xml"
Delete "$INSTDIR\$1\RestSharp.dll"
Delete "$INSTDIR\$1\RestSharp.xml"

!ifdef WEB_SITE
Delete "$INSTDIR\${APP_NAME} website.url"
!endif

RmDir "$INSTDIR\$1\logs"
RmDir "$INSTDIR\$1"
${EndIf}
IfErrors +1 LOOP
FileClose $0

;Delete "$INSTDIR\file.txt"
Delete "$INSTDIR\uninstall.exe"
Delete "$INSTDIR\ETAgentI4U_setup.exe"
Delete "$INSTDIR\ETAgentI4U_setup.exe.config"

RmDir "$INSTDIR"

!ifdef REG_START_MENU
!insertmacro MUI_STARTMENU_GETFOLDER "Application" $SM_Folder
Delete "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk"
Delete "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk"
!ifdef WEB_SITE
Delete "$SMPROGRAMS\$SM_Folder\${APP_NAME} Website.lnk"
!endif
RmDir "$SMPROGRAMS\$SM_Folder"
!endif

!ifndef REG_START_MENU
Delete "$SMPROGRAMS\I4U Agent per eTesseramenti\${APP_NAME}.lnk"
Delete "$SMPROGRAMS\I4U Agent per eTesseramenti\Uninstall ${APP_NAME}.lnk"
!ifdef WEB_SITE
Delete "$SMPROGRAMS\I4U Agent per eTesseramenti\${APP_NAME} Website.lnk"
!endif
RmDir "$SMPROGRAMS\I4U Agent per eTesseramenti"
!endif

DeleteRegKey ${REG_ROOT} "${REG_APP_PATH}"
DeleteRegKey ${REG_ROOT} "${UNINSTALL_PATH}"
SectionEnd

luca89ct is offline   Reply With Quote
Old 28th June 2018, 14:44   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,843
What is $1 inside the loop?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 28th June 2018, 15:22   #3
luca89ct
Junior Member
 
Join Date: Jun 2018
Posts: 8
$1 is the variable with the string that I read each time from file
luca89ct is offline   Reply With Quote
Old 28th June 2018, 15:42   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,843
Quote:
Originally Posted by luca89ct View Post
$1 is the variable with the string that I read each time from file
Yes of course I know that but does it have the value you expect each time through the loop?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 28th June 2018, 17:37   #5
luca89ct
Junior Member
 
Join Date: Jun 2018
Posts: 8
Yes it has the correct value, so during install I have no problems. But only during uninstall.
luca89ct is offline   Reply With Quote
Old 28th June 2018, 23:53   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,843
And which values does it have during uninstall? Is file.txt correct?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 29th June 2018, 08:05   #7
luca89ct
Junior Member
 
Join Date: Jun 2018
Posts: 8
Yes, because this line is ok:

it removes the directory, but not the other files
code:
RmDir "$INSTDIR\$1\logs"
luca89ct is offline   Reply With Quote
Old 29th June 2018, 09:06   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,843
RmDir only removes empty directories by default.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 29th June 2018, 10:25   #9
luca89ct
Junior Member
 
Join Date: Jun 2018
Posts: 8
Yes I know but in this code:

code:

Section Uninstall
${INSTALL_TYPE}

FileOpen $0 $INSTDIR\file.txt r
LOOP:
ClearErrors
FileRead $0 $1
${If} $1 <> ""

Delete "$INSTDIR\$1\App.config"
Delete "$INSTDIR\$1\config.ini"
Delete "$INSTDIR\$1\data.dat"
Delete "$INSTDIR\$1\ETAgentI4U.exe"
Delete "$INSTDIR\$1\ETAgentI4U.exe.config"
Delete "$INSTDIR\$1\Install.bat"
Delete "$INSTDIR\$1\NLog.config"
Delete "$INSTDIR\$1\NLog.dll"
Delete "$INSTDIR\$1\NLog.xml"
Delete "$INSTDIR\$1\RestSharp.dll"
Delete "$INSTDIR\$1\RestSharp.xml"

!ifdef WEB_SITE
Delete "$INSTDIR\${APP_NAME} website.url"
!endif

RmDir "$INSTDIR\$1\logs"
RmDir "$INSTDIR\$1"

${EndIf}
IfErrors +1 LOOP
FileClose $0

Delete "$INSTDIR\uninstall.exe"
Delete "$INSTDIR\ETAgentI4U_setup.exe"
Delete "$INSTDIR\ETAgentI4U_setup.exe.config"

RmDir "$INSTDIR"
SectionEnd



It only remove directory "logs" but doesn't execute commands "Delete" before. Do you know why?
luca89ct is offline   Reply With Quote
Old 29th June 2018, 10:34   #10
luca89ct
Junior Member
 
Join Date: Jun 2018
Posts: 8
Quote:
Originally Posted by Anders View Post
RmDir only removes empty directories by default.
Yes I know but in this code
code:

Section Uninstall
${INSTALL_TYPE}

FileOpen $0 $INSTDIR\cod.txt r
LOOP:
ClearErrors
FileRead $0 $1
${If} $1 <> ""

Delete "$INSTDIR\$1\App.config"
Delete "$INSTDIR\$1\config.ini"
Delete "$INSTDIR\$1\data.dat"
Delete "$INSTDIR\$1\ETAgentI4U.exe"
Delete "$INSTDIR\$1\ETAgentI4U.exe.config"
Delete "$INSTDIR\$1\Install.bat"
Delete "$INSTDIR\$1\NLog.config"
Delete "$INSTDIR\$1\NLog.dll"
Delete "$INSTDIR\$1\NLog.xml"
Delete "$INSTDIR\$1\RestSharp.dll"
Delete "$INSTDIR\$1\RestSharp.xml"

!ifdef WEB_SITE
Delete "$INSTDIR\${APP_NAME} website.url"
!endif

RmDir "$INSTDIR\$1\logs"
RmDir "$INSTDIR\$1"
${EndIf}
IfErrors +1 LOOP
FileClose $0

Delete "$INSTDIR\uninstall.exe"
Delete "$INSTDIR\ETAgentI4U_setup.exe"
Delete "$INSTDIR\ETAgentI4U_setup.exe.config"

RmDir "$INSTDIR"

SectionEnd



It only execute "RmDir" commands and not "Delete" commands. Do you know why?
luca89ct is offline   Reply With Quote
Old 29th June 2018, 12:24   #11
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,843
That is not possible, either the path is wrong or the files are in use. Try Process Monitor...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

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