Old 30th June 2008, 22:12   #41
Sheik
Senior Member
 
Join Date: Feb 2007
Posts: 152
You also need to add in the code I gave above:

Function FileSize
Exch $R0 ;Grab the Inputed path file
System::Call 'kernel32::_lopen(t "$R0", i 0) i .r0' ; Call the API to open the file
System::Call 'kernel32::GetFileSize(i $0, i) i .r1' ; Call API to read file size
System::Call 'kernel32::_lclose(i $0) i' ; API to close the opened file
Push $1
FunctionEnd
Sheik is offline   Reply With Quote
Old 30th June 2008, 22:16   #42
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
Quote:
Originally posted by LoRd_MuldeR
It would accept the virtual disc, of course

As said before: This "Copy Protection" is a farce
If you ask me, the whole thread is a farce

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 30th June 2008, 22:19   #43
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
Quote:
Originally posted by Sheik
You also need to add in the code I gave above:

Function FileSize
Exch $R0 ;Grab the Inputed path file
System::Call 'kernel32::_lopen(t "$R0", i 0) i .r0' ; Call the API to open the file
System::Call 'kernel32::GetFileSize(i $0, i) i .r1' ; Call API to read file size
System::Call 'kernel32::_lclose(i $0) i' ; API to close the opened file
Push $1
FunctionEnd
Yes it makes an installer now but it installs regardless of the DVD/CD being in the drive. I need it to abort if it cannot find the specified file of specified size.

No point talking about copy protection, that's not what I'm trying to do. I want verification. The fact that the game can be cracked, copied and mounted on virtual drive has nothing to do with me. Are you reading my posts or what?
Rich_A is offline   Reply With Quote
Old 30th June 2008, 22:29   #44
Sheik
Senior Member
 
Join Date: Feb 2007
Posts: 152
Sure, the code I gave only does the checking for you.

You still need a "Var" that gets set to 0 or 1, to decide if you want to install or not.

Set it to 0 in the oninit function, then set it to 1 if you come across the file/size you are looking for.

Then before you allow the install, check to see if the variable it set to 1. If it is, install, otherwise bail.
Sheik is offline   Reply With Quote
Old 30th June 2008, 22:32   #45
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
Quote:
Originally posted by Sheik
RedWine, Oh, I am not suggesting that this code is in any way smart... See my comment above about it being "silly" =)

He just seems so insistant on doing it, that oh well, what the heck...

Rich_A,
You need to include logiclib.nsh.

Also, my code was just a quasi-example. I literally wrote it while typing a response... I did not attempt to compile it or anything. Also, you need to change:

!define FILE1_YOU_CARE_ABOUT "FILE1.exe"
!define FILE1_YOU_CARE_ABOUTSIZE "123456789"

To be a file name and filesize that you know exists on the cdrom you are checking.
Suggesting code that you haven't already test doesn't sound as a good idea to me.

@ Rich_A
You should realize that you can't get some copy protection scheme unless you pay the dedicated designers for this.

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 30th June 2008, 22:34   #46
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
Quote:
Originally posted by Sheik
Sure, the code I gave only does the checking for you.

You still need a "Var" that gets set to 0 or 1, to decide if you want to install or not.

Set it to 0 in the oninit function, then set it to 1 if you come across the file/size you are looking for.

Then before you allow the install, check to see if the variable it set to 1. If it is, install, otherwise bail.
Fffffffffshhhhh, right over my head that one. I know people say, "In English please" but can I have that "In code please".

Here's what it looks like at the moment ..

code:

!include "FileFunc.nsh"
!include "logiclib.nsh"
!insertmacro Locate
!insertmacro GetDrives

!define FILE1_YOU_CARE_ABOUT "FILE1.exe"
!define FILE1_YOU_CARE_ABOUTSIZE "123456789"

Section "Example2 (required)"

${GetDrives} "CDROM" "CheckDrive"

SectionIn RO

; Set output path to the installation directory.
SetOutPath $INSTDIR

; Put file there
File "example2.nsi"
File /r D:\Test\*.*

; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\NSIS_Example2 "Install_Dir" "$INSTDIR"

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

SectionEnd

Function CheckDrive
${If} ${FileExists} "$9\${FILE1_YOU_CARE_ABOUT}"
Push "$9\${FILE1_YOU_CARE_ABOUT}"
Call FileSize
Pop $R0
${If} $R0 == ${FILE1_YOU_CARE_ABOUTSIZE}
MessageBox MB_OK "PASSED!"
# Set some Global variable here as "passed".
${Endif}
${Endif}
FunctionEnd

Function FileSize
Exch $R0 ;Grab the Inputed path file
System::Call 'kernel32::_lopen(t "$R0", i 0) i .r0' ; Call the API to open the file
System::Call 'kernel32::GetFileSize(i $0, i) i .r1' ; Call API to read file size
System::Call 'kernel32::_lclose(i $0) i' ; API to close the opened file
Push $1
FunctionEnd



It's installing like a normal installer at the moment regardless of DVD/CD being in drive or not.
Rich_A is offline   Reply With Quote
Old 30th June 2008, 22:59   #47
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
I see you have a function "CheckDrive" specified, but do you ever call it?

If not, do it like this please:

code:
Section "-CheckDriveSection"
Call CheckDrive
SectionEnd

Section "Example2 (required)"
...
SectionEnd

Function CheckDrive
...
FunctionEnd


My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 30th June 2008, 23:26   #48
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
Isn't it called on the ${GetDrives} line?
Rich_A is offline   Reply With Quote
Old 30th June 2008, 23:32   #49
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
Quite possible. I have no idea what the ${GetDrives} makro does

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 1st July 2008, 15:36   #50
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
Hi Sheik, so do the variable need to go in line

# Set some Global variable here as "passed".

If so how please, it's almost complete except for the abort.

I've also discovered that cracked version cannot be used online i.e. racing online. There is a online serial key and I've found the registry entry which is created after entering a valid online serial key. So is there such a thing as ifRegkeyExists?
Rich_A is offline   Reply With Quote
Old 1st July 2008, 16:42   #51
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
Actually I don't think people will like having to have the original game installed. It only needs the CD verification. Sheik can you please give me the code for the variables you're talking about?
Rich_A is offline   Reply With Quote
Old 3rd July 2008, 16:25   #52
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
Managed to make ifFileExist search CDROM only but it's not checking file size at the moment. How can I do that?

code:
!include "FileFunc.nsh"
!include "logiclib.nsh"
!insertmacro Locate
!insertmacro GetDrives

!define FILE1_YOU_CARE_ABOUT "Some File.foo"
!define FILE1_YOU_CARE_ABOUTSIZE "123456789"

Section
${GetDrives} "CDROM" "checkdrive"
SectionEnd

Section "Example2 (required)"

SectionIn RO

; Set output path to the installation directory.
SetOutPath $INSTDIR

; Put file there
File "example2.nsi"
File /r D:\Test\*.*

; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\NSIS_Example2 "Install_Dir" "$INSTDIR"

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

SectionEnd

Function checkdrive
IfFileExists "$9\${FILE1_YOU_CARE_ABOUT}" ItWasFound

Abort "Origianl disc (or copy of it) was not found!"

ItWasFound:
FunctionEnd

Rich_A is offline   Reply With Quote
Old 3rd July 2008, 20:40   #53
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
I'm not going to comment on the legality or ask why... But here's some code for you to try. (I just hacked this together, so you may run into a few syntax errors, but it should give you the basic idea.)

And this *should* work even if you have multiple CD drives.

code:

!include "FileFunc.nsh"
!include "logiclib.nsh"
!insertmacro GetSize
!insertmacro GetDrives

!define FILE1_YOU_CARE_ABOUT "Some File.foo"
!define FILE1_YOU_CARE_ABOUTSIZE "123456789"

var FileDrive ; blank if file not exist

Section
StrCpy $FileDrive ""
${GetDrives} "CDROM" "checkdrive"
${If} "$FileDrive" == ""
Abort "Original disc (or copy of it) was not found!"
${EndIf}
${GetSize} "$FileDrive" "/M=${FILE1_YOU_CARE_ABOUT} /S=0k /G=0" $R1 $R2 $R3
${Unless} $R1 = ${FILE1_YOU_CARE_ABOUT_ABOUTSIZE}
Abort "Invalid file on target disk, $FileDrive!"
${EndUnless}
SectionEnd

Section "Example2 (required)"
; your install code here...
SectionEnd

Function checkdrive
${If} ${FileExists} "$9\${FILE1_YOU_CARE_ABOUT}"
StrCpy $FileDrive "$9"
Push "StopGetDrives"
${Else}
Push "continue"
${EndIf}
FunctionEnd

Comperio is offline   Reply With Quote
Old 4th July 2008, 04:56   #54
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
Thanks Comperio I'll try that later. Why not ask about legal issue, it's important isn't it? Many aren't sure about what is and is not legal. I think this topic has raised some issues for some people regarding the law. Also people don't like to talk about it because they're afraid they might be breaking it, but that's half the problem!

Read my posts here, I've already explained the situation. Conversions of games from one platform to another is not against the law so long as there is proof of purchase and money is not being made. It's considered "fair use". The installer is proof of purchase. I have baught this game and I'm using my own CD to make this installer work. Therefore I'm using it fairly and I'm within my rights. It's the same with any game but many titles have encryted data and I think there are laws against using and cracking encrytped data. But there is no encryption at all in GTR2, that's what's great about it.
Rich_A is offline   Reply With Quote
Old 4th July 2008, 16:15   #55
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
Your code detects the file Comperio but the size code seems to error. The compiler says ..

1 warning:
unknown variable/constant "{FILE1_YOU_CARE_ABOUT_ABOUTSIZE}" detected, ignoring (macro:_=:1)

It creates the installer though and searches for the file, passes the file search but not the file size. Any ideas? Also, is size in bytes or .. ?
Rich_A is offline   Reply With Quote
Old 4th July 2008, 16:36   #56
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
Looks like you found one of my typos... If that's the only one, consider yourself lucky!

Change "${Unless} $R1 = ${FILE1_YOU_CARE_ABOUT_ABOUTSIZE}"
to "${Unless} $R1 = ${FILE1_YOU_CARE_ABOUTSIZE}"

edit: Also, the size should be KB. If you want bytes, then I belive you can change the "k" to a "b". Look up the GetSize header in the appendix section of NSIS help for more info.
Comperio is offline   Reply With Quote
Old 4th July 2008, 19:41   #57
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
Lol so obvious. OK, I'll try it later thanks again.
Rich_A is offline   Reply With Quote
Old 5th July 2008, 12:57   #58
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
Fanatastic it works! Even if it's 1 byte out it won't install. Many many thanks Comperio you are a Major Dude, will make donation now.
Rich_A is offline   Reply With Quote
Old 7th September 2008, 03:51   #59
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
I know the last post here was a long time ago but I need more help. There are at least three version of this game available and there may be more. The code I have works for one installer only at a time because the different versions frustratingly have different names and different file sizes. Is there a way to list several files and file sizes, if it finds one it will continue installation?
Rich_A is offline   Reply With Quote
Old 7th September 2008, 04:26   #60
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
Here is the relevant code ..

code:
!include "FileFunc.nsh"
!include "logiclib.nsh"
!insertmacro GetSize
!insertmacro GetDrives

!define FILE1_YOU_CARE_ABOUT "XXXXXX.XXX"
!define FILE1_YOU_CARE_ABOUTSIZE "XXXXXXX"

var FileDrive ; blank if file not exist

Section
StrCpy $FileDrive ""
${GetDrives} "CDROM" "checkdrive"
${If} "$FileDrive" == ""
Abort "Message."
${EndIf}
${GetSize} "$FileDrive" "/M=${FILE1_YOU_CARE_ABOUT} /S=0B /G=0" $R1 $R2 $R3
${Unless} $R1 = ${FILE1_YOU_CARE_ABOUTSIZE}
Abort "Invalid file on target disk $FileDrive"
${EndUnless}
SectionEnd

Section "EOAA GT V1.00"
SectionIn RO

; Set output path to the installation directory.
SetOutPath $INSTDIR

; Put file there
File /r "X:\X\*.*"

; Write the installation path into the registry
WriteRegStr HKLM "SOFTWARE\EOAA GT" "Install_Dir" "$INSTDIR"

; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\EOAA GT" "DisplayName" "EOAA GT V1.00"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\EOAA GT" "UninstallString" '"$INSTDIR\Uninstall EOAA GT.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\EOAA GT" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\EOAA GT" "NoRepair" 1
WriteUninstaller "Uninstall EOAA GT.exe"
SectionEnd

Function checkdrive
${If} ${FileExists} "$9\${FILE1_YOU_CARE_ABOUT}"
StrCpy $FileDrive "$9"
Push "StopGetDrives"
${Else}
Push "continue"
${EndIf}
FunctionEnd

Rich_A is offline   Reply With Quote
Old 7th September 2008, 12:55   #61
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
I'll make another donation if someone finds a way to do this?
Rich_A is offline   Reply With Quote
Old 7th September 2008, 19:10   #62
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Simply use ${OrUnless} and ${OrIf} where you check for size and file existence to add more cases.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 7th September 2008, 20:08   #63
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
Hi kichik, that's great that it's possible. Could you perhaps use my code and make an example, not sure where to or how to use what you're suggesting, gimme something to try please. I got all this code from this topic, I know the basics but whenever I try something there's always a typo or error.
Rich_A is offline   Reply With Quote
Old 8th September 2008, 06:34   #64
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
For example:
code:
${Unless} $R1 = ${FILE1_YOU_CARE_ABOUTSIZE}
${OrUnless} $R1 = ${FILE2_YOU_CARE_ABOUTSIZE}

code:
${If} ${FileExists} "$9\${FILE1_YOU_CARE_ABOUT}"
${OrIf} ${FileExists} "$9\${FILE2_YOU_CARE_ABOUT}"


NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 8th September 2008, 14:49   #65
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
OK thanks will try some things there.
Rich_A is offline   Reply With Quote
Old 11th September 2008, 15:19   #66
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
It's giving invalid file on target disk which means it failing unless all defined files are present I think.

Here's the code I've got ..

code:

!define FILE1_YOU_CARE_ABOUT "x.x"
!define FILE1_YOU_CARE_ABOUTSIZE "123"
!define FILE2_YOU_CARE_ABOUT "x.x"
!define FILE2_YOU_CARE_ABOUTSIZE "123"
!define FILE3_YOU_CARE_ABOUT "x.x"
!define FILE3_YOU_CARE_ABOUTSIZE "123"

var FileDrive ; blank if file not exist

Section
StrCpy $FileDrive ""
${GetDrives} "CDROM" "checkdrive"
${If} "$FileDrive" == ""
Abort "Please insert GTR2 DVD or CD and try again, verification failed."
${EndIf}
${GetSize} "$FileDrive" "/M=${FILE1_YOU_CARE_ABOUT} /S=0B /G=0" $R1 $R2 $R3
${GetSize} "$FileDrive" "/M=${FILE2_YOU_CARE_ABOUT} /S=0B /G=0" $R1 $R2 $R3
${GetSize} "$FileDrive" "/M=${FILE3_YOU_CARE_ABOUT} /S=0B /G=0" $R1 $R2 $R3
${Unless} $R1 = ${FILE1_YOU_CARE_ABOUTSIZE}
${OrUnless} $R1 = ${FILE2_YOU_CARE_ABOUTSIZE}
${OrUnless} $R1 = ${FILE3_YOU_CARE_ABOUTSIZE}
Abort "Invalid file on target disk $FileDrive"
${EndUnless}
SectionEnd

Section "EOAA GT V1.00"
SectionIn RO

; Set output path to the installation directory.
SetOutPath $INSTDIR

; Put file there
File /r "X:\X\*.*"

; Write the installation path into the registry
WriteRegStr HKLM "SOFTWARE\EOAA GT" "Install_Dir" "$INSTDIR"

; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\EOAA GT" "DisplayName" "EOAA GT V1.00"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\EOAA GT" "UninstallString" '"$INSTDIR\Uninstall EOAA GT.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\EOAA GT" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\EOAA GT" "NoRepair" 1
WriteUninstaller "Uninstall EOAA GT.exe"
SectionEnd

Function checkdrive
${If} ${FileExists} "$9\${FILE1_YOU_CARE_ABOUT}"
${OrIf} ${FileExists} "$9\${FILE2_YOU_CARE_ABOUT}"
${OrIf} ${FileExists} "$9\${FILE3_YOU_CARE_ABOUT}"
StrCpy $FileDrive "$9"
Push "StopGetDrives"
${Else}
Push "continue"
${EndIf}
FunctionEnd

Rich_A is offline   Reply With Quote
Old 11th September 2008, 18:31   #67
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
LogicLib.nsi has ElseUnless, seems to be working with ElseUnless need to do more testing though.
Rich_A is offline   Reply With Quote
Old 11th September 2008, 18:47   #68
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
No ElseUnless allows installation to run regardless of file size has to be OrUnless but it's not working ATM.
Rich_A is offline   Reply With Quote
Old 11th September 2008, 20:57   #69
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
This IMO ought to work, if it doesn't find file1, having file2 or file3 present will permit installer to run but for some reason it's giving the "Invalid file on target disk $FileDrive" error, I know file1 is present and of correct size so it can only mean that it's expecting file2 and file3 to be there also. Perhaps it needs OrGetSize?

code:
Section
StrCpy $FileDrive ""
${GetDrives} "CDROM" "checkdrive"
${If} "$FileDrive" == ""
Abort "Please insert GTR2 DVD or CD and try again, verification failed."
${EndIf}
${GetSize} "$FileDrive" "/M=${FILE1_YOU_CARE_ABOUT} /S=0B /G=0" $R1 $R2 $R3
${Unless} $R1 = ${FILE1_YOU_CARE_ABOUTSIZE}
${GetSize} "$FileDrive" "/M=${FILE2_YOU_CARE_ABOUT} /S=0B /G=0" $R1 $R2 $R3
${OrUnless} $R1 = ${FILE2_YOU_CARE_ABOUTSIZE}
${GetSize} "$FileDrive" "/M=${FILE3_YOU_CARE_ABOUT} /S=0B /G=0" $R1 $R2 $R3
${OrUnless} $R1 = ${FILE3_YOU_CARE_ABOUTSIZE}
Abort "Invalid file on target disk $FileDrive"
${EndUnless}
SectionEnd

Rich_A is offline   Reply With Quote
Old 12th September 2008, 09:14   #70
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
You can't lace ${GetSize} calls between ${Unless} and ${OrUnless}. Get all the sizes into variables and then compare them all at once, or get the size and compare separately.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 12th September 2008, 18:46   #71
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
I'm sorry I don't know what you mean can I have another example please?
Rich_A is offline   Reply With Quote
Old 12th September 2008, 20:40   #72
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
code:
${GetSize} "$FileDrive" "/M=${FILE1_YOU_CARE_ABOUT} /S=0B /G=0" $0 $R2 $R3
${GetSize} "$FileDrive" "/M=${FILE2_YOU_CARE_ABOUT} /S=0B /G=0" $1 $R2 $R3
${GetSize} "$FileDrive" "/M=${FILE3_YOU_CARE_ABOUT} /S=0B /G=0" $2 $R2 $R3
${Unless} $1 = ${FILE1_YOU_CARE_ABOUTSIZE}
${OrUnless} $2 = ${FILE2_YOU_CARE_ABOUTSIZE}
${OrUnless} $3 = ${FILE3_YOU_CARE_ABOUTSIZE}


NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 13th September 2008, 14:46   #73
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
That's what I tried the first time but it say invalid file on target disk. This code require that all 3 files be present doesn't it, if not present abort. I want it to search for file1 and file2 and file3, if ANY of the files are are found and the size is correct, installation continues. It only needs to find one correct file.
Rich_A is offline   Reply With Quote
Old 13th September 2008, 19:57   #74
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
I think I got the LogicLib logic setup correctly. I don't have a computer setup to test it, so try this code on your own to see if it works:
code:
var WhichVersion ; used to keep track of which version you need to install

Function .onInit
${GetDrives} "CDROM" "checkdrive"
${If} $WhichVersion = 0
MessageBox MB_OK "Abort Message"
abort
${EndIf}
; at this point, you could set set section flags based on the value of $WhichVersion

FunctionEnd


Function checkdrive
StrCpy $WhichVersion 0
${If} ${FileExists} "$9\${FILE1_YOU_CARE_ABOUT}"
${GetSize} "$9" "\M=${FILE1_YOU_CARE_ABOUT} /S=0B /G=0" $1 $2 $3
${If} $1 = ${FILE1_YOU_CARE_ABOUTSIZE}
StrCpy $WhichVersion 1
${EndIf}

${OrIf} ${FileExists} "$9\${FILE2_YOU_CARE_ABOUT}"
${GetSize} "$9" "\M=${FILE2_YOU_CARE_ABOUT} /S=0B /G=0" $1 $2 $3
${If} $1 = ${FILE2_YOU_CARE_ABOUTSIZE}
StrCpy $WhichVersion 2
${EndIf}

${OrIf} ${FileExists} "$9\${FILE3_YOU_CARE_ABOUT}"
${GetSize} "$9" "\M=${FILE3_YOU_CARE_ABOUT} /S=0B /G=0" $1 $2 $3
${If} $1 = ${FILE3_YOU_CARE_ABOUTSIZE}
StrCpy $WhichVersion 3
${EndIf}

${EndIf}

; Continue ${GetDrives} if you haven't found what you needed:
${If} $WhichVersion = 0
Push "continue"
${Else}
push "StopGetDrives"
${EndIf}
FunctionEnd

Comperio is offline   Reply With Quote
Old 14th September 2008, 17:54   #75
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
That's great thanks Comperio. I tried it and it aborts even though I'm sure the definitions are correct and CD is in CDROM drive. It needs to continue if WhichVersion(x) is present.

Here is the code, probably not right ..

code:
var WhichVersion ; used to keep track of which version you need to install

Section "EOAA GT V1.00"
SectionIn RO

; Set output path to the installation directory.
SetOutPath $INSTDIR

; Put file there
File /r "x:\x\*.*"

; Write the installation path into the registry
WriteRegStr HKLM "SOFTWARE\EOAA GT" "Install_Dir" "$INSTDIR"

; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\EOAA GT" "DisplayName" "EOAA GT V1.00"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\EOAA GT" "UninstallString" '"$INSTDIR\Uninstall EOAA GT.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\EOAA GT" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\EOAA GT" "NoRepair" 1
WriteUninstaller "Uninstall EOAA GT.exe"
SectionEnd

Function .onInit
${GetDrives} "CDROM" "checkdrive"
${If} $WhichVersion = 0
MessageBox MB_OK "Abort Message"
abort
${EndIf}
; at this point, you could set set section flags based on the value of $WhichVersion

FunctionEnd

Function checkdrive
StrCpy $WhichVersion 0
${If} ${FileExists} "$9\${FILE1_YOU_CARE_ABOUT}"
${GetSize} "$9" "\M=${FILE1_YOU_CARE_ABOUT} /S=0B /G=0" $1 $2 $3
${If} $1 = ${FILE1_YOU_CARE_ABOUTSIZE}
StrCpy $WhichVersion 1
${EndIf}

${OrIf} ${FileExists} "$9\${FILE2_YOU_CARE_ABOUT}"
${GetSize} "$9" "\M=${FILE2_YOU_CARE_ABOUT} /S=0B /G=0" $1 $2 $3
${If} $1 = ${FILE2_YOU_CARE_ABOUTSIZE}
StrCpy $WhichVersion 2
${EndIf}

${OrIf} ${FileExists} "$9\${FILE3_YOU_CARE_ABOUT}"
${GetSize} "$9" "\M=${FILE3_YOU_CARE_ABOUT} /S=0B /G=0" $1 $2 $3
${If} $1 = ${FILE3_YOU_CARE_ABOUTSIZE}
StrCpy $WhichVersion 3
${EndIf}

${EndIf}

; Continue ${GetDrives} if you haven't found what you needed:
${If} $WhichVersion = 0
Push "continue"
${Else}
push "StopGetDrives"
${EndIf}
FunctionEnd

Rich_A is offline   Reply With Quote
Old 15th September 2008, 02:07   #76
Rich_A
Junior Member
 
Join Date: Jun 2008
Posts: 44
Is a typo \M, works with /M. Donation heading NSIS's way, thanks Comperio!

Here's the full code ..

code:
; EOAA GT.nsi

; The name of the installer
Name "EOAA GT V1.00"

; The file to write
OutFile "EOAA GT V1.00.exe"

; The default installation directory
InstallDir $PROGRAMFILES\rFactor

; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\EOAA GT" "Install_Dir"

; Request application privileges for Windows Vista
RequestExecutionLevel admin

;--------------------------------

; Pages

Page components
Page directory
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles

;--------------------------------

!include "FileFunc.nsh"
!include "logiclib.nsh"
!insertmacro GetSize
!insertmacro GetDrives

!define FILE1_YOU_CARE_ABOUT "x.x"
!define FILE1_YOU_CARE_ABOUTSIZE "123"
!define FILE2_YOU_CARE_ABOUT "x.x"
!define FILE2_YOU_CARE_ABOUTSIZE "456"
!define FILE3_YOU_CARE_ABOUT "x.x"
!define FILE3_YOU_CARE_ABOUTSIZE "789"

var WhichVersion ; used to keep track of which version you need to install

Function .onInit
${GetDrives} "CDROM" "checkdrive"
${If} $WhichVersion = 0
MessageBox MB_OK "Abort Message"
abort
${EndIf}
; at this point, you could set set section flags based on the value of $WhichVersion

FunctionEnd

Function checkdrive
StrCpy $WhichVersion 0
${If} ${FileExists} "$9\${FILE1_YOU_CARE_ABOUT}"
${GetSize} "$9" "/M=${FILE1_YOU_CARE_ABOUT} /S=0B /G=0" $1 $2 $3
${If} $1 = ${FILE1_YOU_CARE_ABOUTSIZE}
StrCpy $WhichVersion 1
${EndIf}

${OrIf} ${FileExists} "$9\${FILE2_YOU_CARE_ABOUT}"
${GetSize} "$9" "/M=${FILE2_YOU_CARE_ABOUT} /S=0B /G=0" $1 $2 $3
${If} $1 = ${FILE2_YOU_CARE_ABOUTSIZE}
StrCpy $WhichVersion 2
${EndIf}

${OrIf} ${FileExists} "$9\${FILE3_YOU_CARE_ABOUT}"
${GetSize} "$9" "/M=${FILE3_YOU_CARE_ABOUT} /S=0B /G=0" $1 $2 $3
${If} $1 = ${FILE3_YOU_CARE_ABOUTSIZE}
StrCpy $WhichVersion 3
${EndIf}

${EndIf}

; Continue ${GetDrives} if you haven't found what you needed:
${If} $WhichVersion = 0
Push "continue"
${Else}
push "StopGetDrives"
${EndIf}
FunctionEnd

Section "EOAA GT V1.00"
SectionIn RO

; Set output path to the installation directory.
SetOutPath $INSTDIR

; Put file there
File /r "C:\Folder\Folder\*.*"

; Write the installation path into the registry
WriteRegStr HKLM "SOFTWARE\EOAA GT" "Install_Dir" "$INSTDIR"

; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\EOAA GT" "DisplayName" "EOAA GT V1.00"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\EOAA GT" "UninstallString" '"$INSTDIR\Uninstall EOAA GT.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\EOAA GT" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\EOAA GT" "NoRepair" 1
WriteUninstaller "Uninstall EOAA GT.exe"
SectionEnd

; Uninstaller

Section "Uninstall"

; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\EOAA GT"
DeleteRegKey HKLM "SOFTWARE\EOAA GT"

; Remove files and uninstaller
Delete "$INSTDIR\Uninstall EOAA GT.exe"
Delete "$INSTDIR\rFm\EOAA GT.tga"
Delete "$INSTDIR\rFm\EOAA GT_logo.tga"
Delete "$INSTDIR\rFm\EOAA GT.rfm"
Delete "$INSTDIR\rFm\EOAA GT.bik"

; Remove directories used
RMDir /r "$INSTDIR\GameData\Vehicles\EOAA GT"
RMDir /r "$INSTDIR\GameData\Helmets\EOAA GT"
RMDir /r "$INSTDIR\GameData\Sounds\E_GT"
RMDir /r "$INSTDIR\UIData\EOAA GT"
RMDir /r "$INSTDIR\Music\EOAA GT"

SectionEnd

Rich_A is offline   Reply With Quote
Old 17th September 2008, 20:15   #77
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
LOL!

I was just trying this again and was getting same result and couldn't figure it out. I didn't see your reply about "\M" until I had already spend about an hour of troubleshooting!

I'm glad you figured it out!
Comperio 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