Archive: Create Shortcuts when Checkbox is clicked


Create Shortcuts when Checkbox is clicked
Hello,

i have a little problem. I want to make 4 checkbox. When one of the checkboxes is clicked, the setup is to create a shortcut. But my code, which i used, dont work.

Var

var X1
var X2
var X3
var X4


When state 0...
${If} $X1 == 0
ReadINIStr $X1 "$PLUGINSDIR\kubisumgebung.ini" "field 26" "state"
${AndIf} $X1 == "1"
StrCpy $vPu "1"
${Else}
StrCpy $vPu "0"
${EndIf}

;2
${If} $X2 == 0
ReadINIStr $X2 "$PLUGINSDIR\kubisumgebung.ini" "field 27" "state"
${AndIf} $X2 == "1"
StrCpy $vFu "1"
${Else}
StrCpy $vFu "0"
${EndIf}

;3
${If} $X3 == 0
ReadINIStr $X3 "$PLUGINSDIR\kubisumgebung.ini" "field 28" "state"
${AndIf} $X3 == "1"
StrCpy $vWu "1"
${Else}
StrCpy $vWu "0"
${EndIf}

;4
${If} $X4 == 0
ReadINIStr $X4 "$PLUGINSDIR\kubisumgebung.ini" "field 29" "state"
${AndIf} $X4 == "1"
StrCpy $vSu "1"
${Else}
StrCpy $vSu "0"
${EndIf}


In the installsection
${If} $vPu == "1" 
CreateShortCut "$DESKTOP\Dis.lnk" "$OUTDIR\bac.bat" "" "$INSTDIR\DIR\ICO\dis.ico" ""
${If} $vSu == "1"
CreateShortCut "$DESKTOP\Dis2.lnk" "$OUTDIR\bac.bat" "" "" ""
${If} $vWu == "1"
CreateShortCut "$DESKTOP\Dis3.lnk" "$OUTDIR\bac.bat" "" "" ""
${If} $vFu == "1"
CreateShortCut "$DESKTOP\Dis4.lnk" "$OUTDIR\bac.bat" "" "" ""
${EndIf}
${EndIf}
${EndIf}
${EndIf}


Where is my fault?

Thanks a lot!

The fault is that you're executing the statement,

${If} $X1 == 0
ReadINIStr $X1 "$PLUGINSDIR\kubisumgebung.ini" "field 26" "state"
which is unnecessary, plus it makes the code not to get executed since the $X1 is not initialized with zero.
Either remove that 1st ${If} or initialize $X1 and the rest X's with StrCpy $X1 0.