Old 26th May 2018, 11:05   #1
dzaggiel
Junior Member
 
Join Date: May 2018
Posts: 9
How to create a check if the program is installed?

Hey, I'm learning the NSIS program, I'm trying to do an installer that checks if a program is installed. Unfortunately, no luck. I would like to do a condition that checks for specific registers if is exist that sets it as the default for installation and omits the window with the choice of installation path. If there is no such entry in the registry, it does not skip windows with the choice of the installation path.

I've tried a few tips but I still have a problem.
My code looks like this:

code:
Function findDirectory
ClearErrors
ReadRegStr $0 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 409720" "InstallLocation"
${IF} ${Errors}
MessageBox MB_OK "Not exist"
${ELSE}
${IF} $0 == ""
MessageBox MB_OK "Exist and is empty"
${ELSE}
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 409720" "InstallLocation" ""
${ENDIF}
${ENDIF}
FunctionEnd



I am asking for help because I can not deal with it.
dzaggiel is offline   Reply With Quote
Old 26th May 2018, 14:19   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,888
What is the problem?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 26th May 2018, 14:24   #3
dzaggiel
Junior Member
 
Join Date: May 2018
Posts: 9
The problem is that I do not know how to create what I want. Can you help me? The code above only theoretically checks if there is a location in the registry, I think.
dzaggiel is offline   Reply With Quote
Old 26th May 2018, 19:30   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,888
You can just create that registry value and run it and see what happens.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 26th May 2018, 19:35   #5
dzaggiel
Junior Member
 
Join Date: May 2018
Posts: 9
No, my installer is an add-on to the game so I want to check if the game is installed. I do not want to create a location I want to find the installed game location from the registry and create a condition.
dzaggiel is offline   Reply With Quote
Old 26th May 2018, 19:57   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,888
But during testing you can just create a/the key and test.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 26th May 2018, 20:54   #7
dzaggiel
Junior Member
 
Join Date: May 2018
Posts: 9
But what does the creation of the same location have to do with it? How will it help me?
dzaggiel is offline   Reply With Quote
Old 26th May 2018, 22:41   #8
dzaggiel
Junior Member
 
Join Date: May 2018
Posts: 9
I was tried this command to watch what value have this variable but receives a blank message.


What am I doing wrong?
dzaggiel is offline   Reply With Quote
Old 26th May 2018, 23:45   #9
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,888
From the docs:

Quote:
The error flag will be set and $x will be set to an empty string ("") if the string is not present.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 27th May 2018, 09:22   #10
dzaggiel
Junior Member
 
Join Date: May 2018
Posts: 9
Well, only that the location exists so the string is true.

So what's wrong?
dzaggiel is offline   Reply With Quote
Old 27th May 2018, 11:12   #11
dzaggiel
Junior Member
 
Join Date: May 2018
Posts: 9
I created something like that and it works.



But when installing, the windows copy window appears. Is there any way that this window would not show up?
dzaggiel is offline   Reply With Quote
Old 27th May 2018, 11:18   #12
dzaggiel
Junior Member
 
Join Date: May 2018
Posts: 9
dzaggiel is offline   Reply With Quote
Old 27th May 2018, 11:50   #13
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,888
Don't call CopyFiles if you don't want to copy something

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 27th May 2018, 14:16   #14
dzaggiel
Junior Member
 
Join Date: May 2018
Posts: 9
I used Filecopy but now i using CopyFiles /silent. I need copyfiles to copy original files as backup. So ok nobody help me thanks a lot ;]
dzaggiel 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