Announcement

Collapse
No announcement yet.

Detecting Installed Application

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Detecting Installed Application

    I have this fragment of code that does not seem to work:

    ;cView Section
    Section "Crystal Reports Viewer" CRViewer info
    ReadRegStr $0 HKCU "SOFTWARE\Sand\Third\cView" "Installed"
    IfErrors lblNoApp lblAlreadyInstalled
    lblNoApp:
    SetOutPath "$INSTDIR\sw\cV81"
    File "sw\cV81\*.*"
    ExecWait '"$INSTDIR\sw\cV81\setup.exe " /sms'
    WriteRegStr HKCU "SOFTWARE\Sand\Third" "cView" "Installed"
    lblAlreadyInstalled:
    MessageBox MB_OK "cView already installed!"
    SectionEnd

    I check the value in registry and is there. If I try to run installer again it does not detect that app has been installed.

    Any help is appreciated.

  • #2
    Why not ...
    code:

    ReadRegStr $0 HKCU "SOFTWARE\Sand\Third\cView" "Installed"
    StrCmp $0 "" NoInstall YesInstall
    NoInstall:
    ;Here the code if no installed
    YesInstalled:
    ;Here the code if installed


    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.

    Comment


    • #3
      Make sure the error flag is clear before you execute instructions you later wish to check for errors. Use the ClearErrors instruction before ReadRegStr.
      NSIS FAQ | NSIS Home Page | Donate $
      "I hear and I forget. I see and I remember. I do and I understand." -- Confucius

      Comment


      • #4
        Tried both ideas did not work!

        Thanks for the two ideas above but it still does not work...

        ;--------------------------------
        ;cView Section
        Section "Crystal Reports Viewer" CRViewer info
        ClearErrors
        ReadRegStr $0 HKCU "SOFTWARE\Sand\Third\cView" "Installed"
        StrCmp $0 "" NoInstall YesInstall
        NoInstall:
        ;Here the code if not installed
        SetOutPath "$INSTDIR\sw\cV81"
        File "sw\cV81\*.*"
        ExecWait '"$INSTDIR\sw\cV81\setup.exe " /sms'
        WriteRegStr HKCU "SOFTWARE\Sand\Third" "cView" "Installed"
        YesInstall:
        ;Here the code if installed
        MessageBox MB_OK "cView already installed!"
        SectionEnd

        Comment


        • #5
          You are reading and writing from different keys.

          If you are reading from here:

          ReadRegStr $0 HKCU "SOFTWARE\Sand\Third\cView" "Installed"

          Writing here is not the right place:

          WriteRegStr HKCU "SOFTWARE\Sand\Third" "cView" "Installed"

          It should be:

          WriteRegStr HKCU "SOFTWARE\Sand\Third\cView" "Installed" "1"
          NSIS FAQ | NSIS Home Page | Donate $
          "I hear and I forget. I see and I remember. I do and I understand." -- Confucius

          Comment


          • #6
            It was better...almost there

            It seems that both sections get executed (e.g. YesInstall & NoInstall)..

            ;--------------------------------
            ;cView Section
            Section "Crystal Reports Viewer" CRViewer info
            ClearErrors
            ReadRegStr $0 HKCU "SOFTWARE\Sandvine\Third\cView" "Installed"
            StrCmp $0 "" NoInstall YesInstall

            YesInstall:
            ;Here the code if installed
            MessageBox MB_OK "cView already installed!"

            NoInstall:
            ;Here the code if not installed
            SetOutPath "$INSTDIR\sw\cV81"
            File "sw\cV81\*.*"
            ExecWait '"$INSTDIR\sw\cV81\setup.exe " /sms'
            WriteRegStr HKCU "SOFTWARE\Sandvine\Third\cView" "Installed" "1"
            SectionEnd

            Comment


            • #7
              That would be because you're not skipping NoInstall if YesInstall is executed. You should put Goto done at the end of the YesInstall part and a label called done at the end of the section.
              NSIS FAQ | NSIS Home Page | Donate $
              "I hear and I forget. I see and I remember. I do and I understand." -- Confucius

              Comment


              • #8
                Thanks !!

                You are a genious!

                Comment

                Working...
                X
                😀
                🥰
                🤢
                😎
                😡
                👍
                👎