- NSIS Discussion
- write path into ini
Archive: write path into ini
Zamorro
25th June 2011 09:37 UTC
write path into ini
the user should be able to select a folder and the path should be written into an ini file
my current script:
edit
Name writepath
OutFile writepath.exe
;InstallDir "$PROGRAMFILES\Rockstar Games\Grand Theft Auto San Andreas"
Page directory
Page custom writepath
Page instfiles
Section
SetOutPath $INSTDIR
GetFullPathName $0 ..
SectionEnd
Function writepath
;WriteINIStr $DESKTOP\GTASA_Start.ini MOD-1 path $INSTDIR
WriteINIStr $DESKTOP\GTASA_Start.ini MOD-1 path $0
FunctionEnd
Section
DetailPrint $0
DetailPrint $INSTDIR
SectionEnd
Now i have 2 problems:
1. the installer writes only the content of $INSTDIR into ini but not the content of any other variable like $0
Why?
2. if i use InstallDir "$PROGRAMFILES\Rockstar Games\Grand Theft Auto San Andreas"
for Page directory
and choose then in the installer Page directory a folder which have another name than Grand Theft Auto San Andreas,
for example: G:\1-Mod-Grand Theft Auto San Andreas
then $INSTDIR returns G:\1-Mod-Grand Theft Auto San Andreas\Grand Theft Auto San Andreas
It creates the folder of InstallDir as subfolder of the choosen directory
How to prevent that?
MSG
25th June 2011 11:25 UTC
1: Because you only write $INSTDIR to the ini file. You need to write $0 using a second WriteINIStr command. (What made you think that NSIS would write $0 to the ini file, when you never told it to do that?)
2: It's all in the manual: http://nsis.sourceforge.net/Docs/Chapter4.html#4.8.1.21
(Short version: try appending a \ to your installdir.)
Zamorro
25th June 2011 11:49 UTC
Originally posted by MSG
1: Because you only write $INSTDIR to the ini file. You need to write $0 using a second WriteINIStr command. (What made you think that NSIS would write $0 to the ini file, when you never told it to do that?)
shure did i wrote
WriteINIStr $DESKTOP\GTASA_Start.ini MOD-1 path $0
but the installer don't write the content of $0
so i removed this line from script
and meanwhile added it again with edit button
2: It's all in the manual:
jep, a backslash at the end
But Jesus, now i got the bigest problem
I want to start the gta_sa.exe of San Andreas
Exec '"G:\Grand Theft Auto San Andreas\gta_sa.exe"'
Quit
But it caused a heavy bug with message "game must be closed"
I had to restart my pc to get it working again
Is NSIS able to start a 3dGame?
I tried then to make a shortcut
CreateShortCut "$DESKTOP\StartGTASA.lnk" "G:\Grand Theft Auto San Andreas\gta_sa.exe" "" "G:\Grand Theft Auto San Andreas\gta_sa.exe" 0 SW_SHOWNORMAL ALT|CONTROL|F8
But one info was missing: the folder name where the exe should run
and this is the reason that the game doesn't start
view the image of the shortcut properties:
http://thumbnails47.imagebam.com/137...1137968661.jpg
MSG
25th June 2011 15:37 UTC
Originally posted by Zamorro
shure did i wrote
WriteINIStr $DESKTOP\GTASA_Start.ini MOD-1 path $0
but the installer don't write the content of $0
Check the contents of $0 using a messagebox.
Originally posted by Zamorro
But one info was missing: the folder name where the exe should run
and this is the reason that the game doesn't start
It's all in the manual:
http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.3.4 (Hint: look for 'working directory').
Originally posted by Zamorro
Is NSIS able to start a 3dGame?
NSIS doesn't care what kind of exe it is. It just launches the exe. Since the shortcut doesn't work without a proper working directory, this is probably also the cause of the problem here. SetOutPath should do the trick here.
By the way, my name isn't Jesus. Please address people properly.
Zamorro
27th June 2011 22:23 UTC
Originally posted by MSG
Check the contents of $0 using a messagebox.
works now
NSIS doesn't care what kind of exe it is. It just launches the exe. Since the shortcut doesn't work without a proper working directory, this is probably also the cause of the problem here. SetOutPath should do the trick here.
works with
ExecShell "open" "$gamerun"
Thanks for all
just one last question
i would like to get the DirRegKey for InstallDirRegKey HKLM "Software\Rockstar Games\GTA San Andreas" ""
I allready asked somewhere regarding to GTA IV and got the answer:
I don't think the GTA4 regkeys will be in HKCU, because it installs to program files which requires admin access. Admin installers (should) write to HKLM. If it IS stored in HKCU, then it will be the admin's HKCU, so either way you need to elevate your installer. Use requestexecutionlevel admin and use the UserInfo plugin in .onInit to verify admin access.
i checked the UserInfo.nsi but don't know how it could help
Then i installed the UAC plugin and tried that script:
http://nsis.sourceforge.net/UAC_plug-in with
!include UAC.nsh but the compiler dindn' accept this:
UAC::RunElevated
what is missing?
MSG
28th June 2011 05:59 UTC
Please do not use the UAC plugin for something this simple. It's very complex to use, and you don't need it at all.
Simply do:
requestexecutionlevel admin
function .onInit
UserInfo::GetAccountType
Pop $1
${If} $1 != "Admin"
MessageBox MB_OK "Requires admin!"
quit
${EndIf}
functionend
Note that if you only want to READ the regkey, you can just do that from a normal userlevel installer. But if the game was installed to Program Files for example and you want to *write* something there, then yes, admin access is a requirement.