I develop an app which creates a Windows Service that creates a folder inside
C:\Windows\System32\config\systemprofile\AppData\Roaming
, called MyApp
.
I use NSIS to create the installer of my app. Everything works fine, except the NSIS script is not deleting the MyApp
when executing the generated uninstaller.
After debugging, I observed that NSIS doesn't find the MyApp
folder, which is pretty weird, because if I run cd /d C:\Windows\System32\config\systemprofile\AppData\Roaming && dir /a
I can see it there
However, if I generate an installer with the following content
OutFile "installer.exe"
; RequestExecutionLevel admin
Section
; SetShellVarContext all
nsExec::ExecToStack '"$SYSDIR\cmd.exe" /c "cd /d $SYSDIR\config\systemprofile\AppData\Roaming && dir /a"'
Pop $0 # return value/error/timeout
Pop $1 # printed text, up to ${NSIS_MAX_STRLEN}
MessageBox MB_OK "My result: $1"
SectionEnd
I don't get the same result as in the command line.
As you can see, I already tried setting SetShellVarContext all
or RequestExecutionLevel admin
, but without any success, so I commented them out. I also tried to execute
nsExec::ExecToStack '"$SYSDIR\cmd.exe" /c "cd /d C:\Windows\System32\config\systemprofile\AppData\Roaming && dir /a"'
, but with no success.
Any idea why this happens and how can I solve the problem? In the end, I would like to be able to execute
RMDir /r "$SYSDIR\config\systemprofile\AppData\Roaming\MyApp"
On 64-bit Windows, the file system redirector will force a 32-bit application to access c:\Windows\SysWow64 when it thinks it's accessing system32.
RequestExecutionLevel Admin
!include x64.nsh
Section Uninstall
${DisableX64FSRedirection}
RMDir /r "$SysDir\config\systemprofile\AppData\Roaming\MyApp"
${EnableX64FSRedirection}
SectionEnd