- NSIS Discussion
- Setting a reg key with variables? And calling with batch?
Archive: Setting a reg key with variables? And calling with batch?
-Gamah
8th July 2008 00:28 UTC
Setting a reg key with variables? And calling with batch?
Here's what my script uses to find someone's game directory (this is an automatic addon installer)
Function .onInit
Call GetSteamAccountName
Pop $R0 ; CaDDy-
Pop $R1 ; E\Games\Steaaam
# Check if Steam is installed
StrCmp $R0 "" 0 +3
MessageBox MB_OK|MB_ICONSTOP $(SteamNotInstalled)
Abort
# It is installed so set INSTDIR
StrCpy $INSTDIR "$R1\SteamApps\$R0\garrysmod\garrysmod"
The "$R1\SteamApps\$R0\garrysmod\garrysmod is what i want written to a registry key.
This brings me to the second question, is it possible to call up a registry key as a variable in a batch file? If so, how would I do so?
Afrow UK
8th July 2008 14:31 UTC
Use ReadReg* and WriteReg* all of which are in the documentation. You could read a value in NSIS and pass it via the batch's command-line. However, what can you do in a batch that you cannot do in NSIS?
Stu
-Gamah
8th July 2008 17:19 UTC
Originally posted by Afrow UK
However, what can you do in a batch that you cannot do in NSIS?
Stu [/B]
svn checkout and svn export :P
edit
So something like "WriteReg HKLM\Software\UltimateGmodPack\GmodInstdir "$R1\SteamApps\$R0\garrysmod\garrysmod\" will write the actual values in on the key and not just the $R1 and $R0?
-Gamah
8th July 2008 17:41 UTC
Also, if i could just use NSIS to set an environment variable, that would make things much easier.
Afrow UK
8th July 2008 17:42 UTC
I'll let you do a search for that one.
Stu
-Gamah
8th July 2008 18:06 UTC
I see nothing in the documentation on SETTING an environment variable, only the ones that NSIS uses.
Afrow UK
8th July 2008 19:24 UTC
There's also this forum you can search as well as the Wiki.
Stu
-Gamah
8th July 2008 20:48 UTC
Okay I've done searching, now why doesn't this work?
Function .setReg
WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "GMOD_DIR" "$R1\SteamApps\$R0\garrysmod\garrysmod"
FunctionEnd
Comperio
8th July 2008 21:00 UTC
What does the registry look like after calling the function?
Also, you might add a message box in your function function as a debug tool to see that $R0 and $R1 are set properly.
Afrow UK
8th July 2008 21:27 UTC
In what way does it not work? Are you calling the function? The . in front of the name does not make it get called automatically.
Stu
-Gamah
8th July 2008 21:40 UTC
After compiling and running the installer, the GMOD_DIR entry IS MADE IN THE KEY properly, with $R0 and $R1 set and everything.
But when i go to command prompt and type %GMOD_DIR% it tells me that environment variable GMOD_DIR is not defined (though i'm LOOKING AT IT in regedit.exe
any ideas?