# Setup programs for Windows

Alberto, why did you chose NSIS to build setup programs? I don’t like it because its scripting language seems a mix between assembly and shell scripting and it doesn’t even have flow control statements, you have to use `Goto`!

Moreover you have to do manually everthing, for instance to copy a file that later can be uninstalled you need this code:

```; Copy the file
File "example.exe"

; Create shortcuts.
CeateDirectory "\$SMPROGRAMS\Example"
CreateShortCut "\$SMPROGRAMS\Example\Uninstall.lnk" "\$INSTDIR\uninstall.exe" "" "\$INSTDIR\uninstall.exe" 0
CreateShortCut "\$SMPROGRAMS\Example\Example.lnk" "\$INSTDIR\example.exe" "" "\$INSTDIR\example.exe" 0

; Copy the uninstaller.
WriteUninstaller "uninstall.exe"

; Write the uninstall keys for Windows.
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example" "DisplayName" "NSIS Example"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example" "UninstallString" '"\$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersionUninstall\Example" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example" "NoRepair" 1 WriteUninstaller "uninstall.exe"
```

And then you have to uninstall everything manually:

```; Delete registry keys.
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example"

; Remove files and uninstaller.
Delete \$INSTDIR\example.exe
Delete \$INSTDIR\uninstall.exe

; Remove shortcuts.
Delete "\$SMPROGRAMS\Example\Uninstall.lnk"
Delete "\$SMPROGRAMS\Example\Example.lnk"
RMDir "\$SMPROGRAMS\Example"

; Remove the program directory.
RMDir "\$INSTDIR"
```

I prefer Inno Setup, the nice thing is that for common tasks (copying files, creating shortcuts, adding registry keys, etc.) you only have to write a simple ini-like file, but if you need something more powerful you can use Pascal scripting.

The previous example in Inno Setup would be:

```[Files]
Source: "example.exe"; DestDir: "{app}"

[Icons]
Name: "{group}\Example"; Filename: "{app}\example.exe"
Name: "{group}\Uninstall"; Filename: "{uninstallexe}"
```

Please, use Inno Setup!